DockerPlay
1
Chapter 0312 mins • beginner

Container Lifecycle & Management

Running, Stopping, Inspecting, and Removing Containers

What You Will Master:

Understand the full container lifecycle state machine
Run containers in detached and interactive modes
Master `docker run`, `docker ps -a`, `docker stop`, `docker start`, and `docker rm`

The Container State Machine

A container transitions through distinct states during its life: 1. **Created**: Layer allocated, network assigned, not yet started. 2. **Running**: Process actively executing inside container. 3. **Stopped / Exited**: Main process has exited or received SIGTERM/SIGKILL. 4. **Removed**: Container and its writable layer completely deleted.
Interactive Lab

Run, Stop, and Remove a Container

Run an nginx web server, verify it with `docker ps`, stop it, and restart it.

0/2 Steps Done
Step 1: Run an nginx container in detached mode named "web"

Run `docker run -d --name web nginx:latest`

Step 2: Stop the web container

Run `docker stop web`

Chapter Knowledge Check

Take the interactive MCQ test to unlock bonus XP

Sponsor & Resources