Container lifecycle management encompasses the complete journey of a container from creation through termination, including state transitions, process handling, and cleanup. Understanding lifecycle mechanics is critical for building resilient containerized applications that start correctly, handle signals gracefully, and shut down without data loss or dropped connections. The most common pitfall is the PID 1 problem—when your main process doesn't properly reap zombie children or handle termination signals, leading to resource leaks and unclean shutdowns that orchestrators like Kubernetes misinterpret as application failures.
What This Cheat Sheet Covers
This topic spans 15 focused tables and 120 indexed concepts, 111 flashcards. Below is a complete table-by-table outline of this topic, spanning foundational concepts through advanced details.
A jump-to index of every table row in this cheat sheet.
An interactive map of every table and concept in this topic.
Table 1: Container States
The six official Docker container states form the foundation of lifecycle reasoning; every container is in exactly one of these states at any moment, and transitions between them are triggered by specific commands or conditions.
| State | Example | Description | |
|---|---|---|---|
docker start my-container | • Main process (PID 1) is executing • container is operational and consuming resources. | ||
docker create nginx | • Container exists but has not been started • filesystem and config are prepared, no process is running. | ||
docker ps -a shows Exited (0) | • Main process terminated with exit code • container stopped but resources not yet cleaned. | ||
docker pause my-container | • All processes frozen via cgroup freezer • memory state preserved but CPU execution halted. | ||
docker restart my-container | Transitional state during stop-then-start sequence triggered by restart policy or manual command. | ||
Container in dead state | • Removal attempted but failed • cannot be restarted; force-remove with docker rm -f. |