Container Lifecycle
A container is a process that gets created and eventually disappears, moving between Created, Running, Paused and Exited along the way. `docker run` is really create and start combined, and `stop` sends SIGTERM first, waits, then forces SIGKILL. Knowing which command causes which transition also tells you exactly when your data goes away.
01Container Lifecycle
Concept at a GlanceA container is, in the end, a single process. It moves through a handful of states between being created and disappearing.
docker create · builds the container from the image and stops there. The writable layer and config are ready, but no process is running yet.
docker start · the process comes up. The familiar docker run is really create and start in one command.
docker pause · freezes the process with the cgroup freezer instead of killing it. Memory state is kept intact.
docker unpause · the frozen process resumes exactly where it stopped.
docker stop · sends SIGTERM first to give the process time to clean up. If it hasn't finished within 10 seconds by default, SIGKILL forces it.
When the process ends it leaves an exit code and becomes Exited. That code is how you tell a clean shutdown from a failure.
An Exited container still holds its writable layer. Bring it back with start and whatever it accumulated is still there.
docker rm · this is where the container and its writable layer disappear together. Exactly why anything worth keeping belongs in a volume.
Try it yourself · docker stop
02 Understand It Simply
For EveryoneA container is a single process moving between Created, Running, Paused and Exited. run is create plus start, and the writable layer disappears at rm.
create builds the container from an image without running it (Created).
start brings the process up (Running).
stop goes SIGTERM → a 10-second grace period by default → SIGKILL, leaving it Exited.
An Exited container still holds its writable layer, so restarting it keeps the data — but rm deletes that layer along with the container.
- –Designing graceful shutdown (handling SIGTERM)
- –diagnosing failures from exit codes
- –setting restart policies
- –and understanding when container data disappears
03 Frequently Asked Questions
FAQWhat is Container Lifecycle?+
A container is a process that gets created and eventually disappears, moving between Created, Running, Paused and Exited along the way. `docker run` is really create and start combined, and `stop` sends SIGTERM first, waits, then forces SIGKILL. Knowing which command causes which transition also tells you exactly when your data goes away.
Where is Container Lifecycle used?+
Designing graceful shutdown (handling SIGTERM), diagnosing failures from exit codes, setting restart policies, and understanding when container data disappears.
What's a simple analogy for Container Lifecycle?+
A container is a single process moving between Created, Running, Paused and Exited. run is create plus start, and the writable layer disappears at rm.
