What happens when a container starts?
When a container starts, Docker takes an image and creates an isolated process from it. The sequence of steps at the junior level looks like this:
1. Docker takes the image
An image is a template (layers with a file system and configuration). It is the foundation of the future container.
2. A writable layer is created
On top of the image layers, Docker adds a changeable layer, where all the container's changes (logs, temporary files, and so on) will go.
3. The container gets isolated resources
Docker configures namespaces and cgroups so that the container:
- sees only its own processes,
- has its own file system,
- has its own network environment,
- can use limited resources.
4. The main process starts
Docker runs the command specified in CMD or ENTRYPOINT in the image.
This process = "the container's life".
5. The container runs as long as the process lives
If the process ends, the container stops automatically.
Summary in one phrase
When a Docker container starts, an isolated environment is created from the image, a writable layer is added on top, and the main process starts, on which the container's life depends.
If you want, I can break down the same chain at the middle level (with details about OverlayFS, the PID namespace, the network namespace, and so on).
Short Answer
Interview readyA concise answer to help you respond confidently on this topic during an interview.