Container life cycle
Using containers is not as intuitive as the tools that we are used to work with. In this section, we will go through Docker usages from the most fundamental ideas to the extent that we are able to benefit from containers.
Docker basics
When docker run alpine ls
is executed, what Docker did behind the scenes is:
- Find the image
alpine
locally. If not found, Docker will try to find and pull it from the public Docker registry to the local image storage. - Extract the image and create a container accordingly.
- Execute the entry point defined in the image with commands, which are the arguments after the image name. In this example, it is
ls
. The entry point by default is/bin/sh -c
on the Linux-based Docker. - When the entry point process is exited, the container then exits.
An image is an immutable bundle of codes, libraries, configurations, and everything needed to run an application. A container is an instance of an image, which would actually be executed during runtime. You can use...