Learning and playing with Docker through the browser

23/01/2020 tipsdocker

docker logo

Having a Docker environment on your own machine can be somewhat complicated in some situations. One example is for those who use Windows 10 Home, which does not support the typical Docker installation because of a feature (Hyper-V) that is only available in the Pro version of the system. Of course, there are workarounds and alternatives to solve this, but usually at the cost of important resources for those who use more modest machines, in addition to the extra work required to get everything working. And it gets even more complicated when trying to simulate the scenario of multiple nodes (machines) working together...

The Solution

Well, there is a very simple alternative, and it costs nothing, which you can use directly in your browser! It's Play With Docker! An amazing tool sponsored by Docker Inc. itself.

Here's how PWD works:

  1. You log in.
  2. You click Start.
  3. You are directed to the Playground and ready, you can start creating instances (machines) and do whatever you want with them.

Some Features of PWD

Basic (and Extremely Simplified) Concept of Docker

Docker basically works like this: you create images of your applications, and with these images, you can create containers without worrying about the environment in which they will be running, as the containers operate in isolation and without interference from the machine they are running on, and inside the images will be described everything the containers will need for your applications to work (software versions, languages, packages, etc).

Note: This does not even come close to explaining all the capabilities and advantages of Docker, so I recommend taking a look at other articles and even the Docker documentation to get a better idea of what it can offer.

Starting a Container Using a Ready-Made Image

An image is an application that has been 'containerized' and is ready to become a new container (or several). In this example, I will use an image of Quick Express, which is a boilerplate for REST APIs in Node.js. This image is hosted on Docker Hub, which is a repository maintained by Docker Inc. itself and is free to host public images.

Starting the Container

To run a container using this image, we only need a single command:

docker run -d -p 80:3000 -e "AUTH_SECRET=mySecretKey" --name quick-express josecfreittas/quick-express

Understanding the Command:

Checking if the Container is Active

You can check the list of running containers using this command:

docker ps

When you run this command, the expected result is that it lists the container we started in the previous step.

Accessing the API

Since a port has been set to expose our container (80), you can already access it through the URL provided by PWD:

And this is the result:

With just one command!