Hands-On LabBeginner

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.

60 minEstimated time
5Guided steps
AutoVerification
IsolatedSandbox
Master Docker Container Lifecycle: Pause, Stop, Kill, and Restart

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 pause and docker unpause to freeze a container's processes via the cgroup freezer without releasing its ports or network namespace.
  • Trace the docker stop flow 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 stop with docker kill by 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 restart and configure a --restart unless-stopped policy 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.

[CHECK] validation_activelive
Inspecting deployed resources...
Verifying configuration state...
✓ Step requirements satisfied

More labs like this

Related reading

PremiumIncluded in Premium
Duration
60 min
Steps
5

Environment

Dedicated VM IDE

Every lab includes

  • Real environment, pre-credentialed
  • Automated checks on every step
  • Isolated sandbox, auto cleanup
  • AI-recommended next steps

Lab curriculum

  1. 01

    Getting Started with Docker IDE

  2. 02

    Run nginx Detached and Pause It Without Stopping the Container

    1 automated check

  3. 03

    Gracefully Stop a Container with SIGTERM and a Grace Period

    1 automated check

  4. 04

    Compare Stop and Kill Using a Trap-Aware Busybox Container

    1 automated check

  5. 05

    Restart Containers and Configure a unless-stopped Restart Policy

    1 automated check

Skills validated

Docker

Not the lab you were looking for?

Browse 250+ hands-on labs across AWS, Azure, Kubernetes, Docker, and cloud security.

Explore the catalog