Master Docker Container Lifecycle: Pause, Stop, Kill, and Restart
Move containers through every state in the Docker lifecycle (pause, stop, kill, restart) by reading the signals and exit codes that drive each transition.

Lab overview
A running Docker container is not a single binary state. It is a tiny state machine that moves between created, running, paused, exited, and restarting, with a Linux signal driving every transition. When docker stop sends the image's stop signal (SIGTERM by default), a well-behaved process drains in-flight requests before exiting. When docker kill sends SIGKILL, the kernel terminates the process immediately. The difference between a clean exit (0 or 143) and exit code 137 is the difference between a graceful shutdown and a hard cut, and in production it is the difference between an HTTP request that completes and an HTTP request that becomes a 502.
Every production container platform (Kubernetes, ECS, Docker Swarm, Nomad) is built on top of these primitives. Pod termination in Kubernetes is literally SIGTERM, a terminationGracePeriodSeconds timer, then SIGKILL. Restart policies decide whether a crashed queue worker comes back automatically or stays dead until a human looks at it. In this lab, you will drive a real Docker daemon through every state in the container lifecycle, watch the signals fire, read the exit codes Docker records, and configure a restart policy that brings a crashed container back on its own.
Objectives
Upon completion of this beginner level lab, you will be able to:
- Identify the five states in the Docker container lifecycle (created, running, paused, exited, restarting) and read each one from
docker inspect. - Use
docker pauseanddocker unpauseto freeze a container's processes via the cgroup freezer without releasing its ports or network namespace. - Trace the
docker stopflow end-to-end: SIGTERM is sent, a configurable grace period elapses, and the container exits cleanly with code 0 (the app handled the signal) or 143 (128 + 15, the OS default handler). - Contrast
docker stopwithdocker killby attaching a trap-aware busybox process and watching SIGKILL produce exit code 137 (128 + 9) with no chance to clean up. - Restart a stopped container in place with
docker restartand configure a--restart unless-stoppedpolicy that auto-recovers from crashes but respects manual stops.
Who is this lab for?
This lab is designed for:
- Aspiring DevOps engineers and SREs preparing for the Docker Certified Associate (DCA) certification who need hands-on experience with the container lifecycle and signal handling.
- Backend developers learning to implement graceful shutdown and restart policies for production containers.
- Engineers preparing for the Certified Kubernetes Administrator (CKA) exam who want to understand the SIGTERM/SIGKILL primitives behind pod termination.
Verified against your live environment
An automated validation engine inspects your actual resources and configurations as you work. Completion means the task was performed, not multiple choice, real-world proficiency.
More labs like this
Deploy Multi-Container Apps with Docker Compose
Author a compose.yaml that runs nginx, a Python API, and Postgres as a single declarative multi-service stack.
Containerize and Deploy a Multi-Container Application to Azure Container Apps
Build Docker images for a restaurant menu app, push to ACR, and deploy frontend and backend containers to Azure Container Apps.
Docker Container Networking - Bridges, Custom Networks, and DNS
Master Docker networking with the default bridge, user-defined bridges, embedded DNS, and network isolation.
Related reading
Environment
Every lab includes
- Real environment, pre-credentialed
- Automated checks on every step
- Isolated sandbox, auto cleanup
- AI-recommended next steps
Lab curriculum
- 01
Getting Started with Docker IDE
- 02
Run nginx Detached and Pause It Without Stopping the Container
1 automated check
- 03
Gracefully Stop a Container with SIGTERM and a Grace Period
1 automated check
- 04
Compare Stop and Kill Using a Trap-Aware Busybox Container
1 automated check
- 05
Restart Containers and Configure a unless-stopped Restart Policy
1 automated check
Skills validated
Not the lab you were looking for?
Browse 250+ hands-on labs across AWS, Azure, Kubernetes, Docker, and cloud security.