I wrote quick "Hands-on" for beginners to cover docker basics with simple containers so I won't go into details of complex application, service definitions or swarms. What I want to do is run a webserver inside a container with persistent data
Check Docker
Let’s check if docker is running
For now there are no images available but this will change in a little:
There are also no running containers:
Maybe also quickly check the network configuration especially what IP’s our docker host has:
Get your first image
Images have to be downloaded to the docker host once in order to be able to create containers. You can simply pull images with pull command{.external-link}
Once done, you can see the images with images command{.external-link}. So let’s pull the webserver image ngnix and then check
Details on how this image is composed can be found by checking the image description on Docker-Hub, in the original Dockerfile or by inspecting the image with the docker inspect{.external-link} nginx command
Start your first container
A container can be started by docker run{.external-link} command:
As you can see, so far nothing else happens. Well not entirely true, let’s quickly open another terminal and check whether we have a running container
So there is a container running and it is named “pedantic_yonath” - this name is given automatically by docker, but you can force a proper name by aggregating parameter -name. So when the container is running, then we should be able to connect to the webserver right? Well first we need to figure out the ip address of the container, which can be simply achieved by inspect command