How Does a Docker Container Run on a Computer?
Asked by
MellowPine42
When I start a Docker container, what is actually running on the computer? Is the container itself a separate program, or does the Docker Engine run as a program that contains and manages the container? I'm trying to understand the relationship between the Docker client, Docker Engine, and the container process.
Answers
A container is essentially a regular process, or a group of processes, running on the host operating system. Docker makes it look isolated by using features such as namespaces for things like processes and networking, plus control groups for limiting resources. It also gives the process a container image containing its filesystem and required files.
Reply to this answer
The Docker Engine is the background service that manages containers. When you run a command through the Docker client, the engine asks a container runtime to create the container from an image, set up its filesystem and isolation, and start the application process. The engine remains running separately; it doesnโt literally contain the container inside itself like a virtual machine does.
MellowPine42: That helpsโso Docker is managing the setup and lifecycle, while the application inside the container is still running as a host-level process.
Reply to this answer
A useful simplified chain is: Docker CLI sends a request to the Docker Engine, the Engine uses a runtime such as containerd and runc, and the runtime starts the program with the requested isolation. If the container runs a web server, the web server is the main process inside that container. Stopping that process normally stops the container as well.
Reply to this answer
Add your answer
Answers are reviewed before publication.
CopperLynx19: So the container isnโt a tiny virtual machine with its own kernelโit shares the host kernel while getting an isolated environment around the process.