Docker is a major change in the way we develop software. But it can be a bit challenging for a developer to enter the container world. This series of articles is an answer to a developer wanting to onboard the Docker train. It is not designed to be a complete docker training (these already exist), but rather a starter kit to quickly get up to speed.
There is not a fixed number of parts for this series as I am not sure yet how far I want to go (for instance I am not sure yet if I will talk about Docker compose or Docker Swarm). Of course, do not hesitate to point any mistake or omission.
OS does not matter anymore. Docker is now available natively on Windows 10 (from 1511 November update, Build 10586), OSX and Linux. I use it without any problem on OSX and a debian at work, and on Windows 10 and a Linux Mint at home. What I recommand though is to avoid the non native solutions for older OSX and Windows 7/10. My experience with them was just awful: a lot of issues, of instabilities as well as some strange behaviors.
Well, this part will be pretty simple. Go to the official page, and follow the official tutorial:
In the following, I will assume you have the basic understanding that the tutorial gave you.
Lifecycle of a container
A Docker Container can have multiple states. Here is a complete list of the different states as well as the associated commands from the official documentation:
As you can see, there are multiple state possible.
The main states are:
created: your container has been created. This means you have created an instance of an image. You get to this state by running the command docker create
|Remember what you saw in the tutorial, an image does not have a state and never changes.|
paused: A paused container is in a frozen state but its main process has not been stopped (the SIGTERM signal was not sent from docker to PID1 process). The container has not released its ressources (eg memory). From a running container you reach this state with the docker pause. It can be unfrozen using the docker unpause.
stopped: When stopping a container, the SIGTERM signal has been sent from docker to the main process. After a waiting time (10 seconds by default), the main process will receive a SIGKILL signal. You can stop a container using docker stop. NB: You can also directly send a SIGKILL signal using docker kill. It is probably not a good idea if you wish to restart your container. You can move from a stopped container to a running container using the docker start command.
That is it for this post, you can jump to the next one: Docker starter kit part 2: Anatomy of an Image and a Container