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.
01 Concept at a Glance
Interactive Step-by-StepA container is, in the end, a single process. It moves through a handful of states between being created and disappearing.
02 Understand It Simply
For EveryoneLike a car. Buying it and leaving it parked is create (Created); turning the key is start (Running); idling briefly is pause; switching off is stop (Exited). The car stays yours until you scrap it (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?+
Like a car. Buying it and leaving it parked is create (Created); turning the key is start (Running); idling briefly is pause; switching off is stop (Exited). The car stays yours until you scrap it (rm).
