Oh My Algorithm
Concept GuideState Transitions · create/start/stop

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-Step
Container Lifecycle · Commands & State Transitions
⌨️docker CLI
docker CLI
📦Container process
none
docker create
image → Created
docker start
Created → Running
docker pause
Running → Paused
docker unpause
Paused → Running
docker stop
SIGTERM → 10s → SIGKILL
exit code
exit 0 · Exited
docker rm
Exited → removed

A container is, in the end, a single process. It moves through a handful of states between being created and disappearing.

Logic Node1 / 10

02 Understand It Simply

For Everyone
🔑Analogy

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).

💡In Plain Words

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.

📍Where It's Used
  • Designing graceful shutdown (handling SIGTERM)
  • diagnosing failures from exit codes
  • setting restart policies
  • and understanding when container data disappears

03 Frequently Asked Questions

FAQ
What 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).

Guide Progress0%