World map

 

BM: Baca dalam Bahasa Melayu

World D1: First Containers

Container states: ps -a and inspect

You will learn: the states a container moves through, and how to read them.

Checked with Docker Engine 29 on 31 Oct 2026

The problem

docker ps lists one box: web, Up. The box called job is not in the list. Docker transcript: $ docker ps CONTAINER ID IMAGE COMMAND CREATED STATUS PORTS NAMES b7f212d01a85 nginx:1.30-alpine "/docker-entrypoint.…" 6 seconds ago Up 6 seconds 80/tcp web

Your laptop~

  • No open hatches

Lunchboxes (containers)

  • webrunning
    from nginx:1.30-alpine
  • jobstopped
    from alpine:3.22

Frozen packs (images)

  • alpine:3.221 layers · 12.9MB · in use
  • nginx:1.30-alpine8 layers · 93.5MB · in use

2 containers (1 running), 2 images, 0 lockers.

You made two boxes: web and job. But docker ps shows only web. Where did job go?

Try it

docker ps lists running boxes only. Add -a to see all of them, stopped ones too.

Your laptop~

  • No open hatches

Lunchboxes (containers)

  • webrunning
    from nginx:1.30-alpine
  • jobstopped
    from alpine:3.22

Frozen packs (images)

  • alpine:3.221 layers · 12.9MB · in use
  • nginx:1.30-alpine8 layers · 93.5MB · in use

2 containers (1 running), 2 images, 0 lockers.

Watch

A box has a life cycle: The states a container moves through: created, running, paused, exited, removed.. Each command moves it one step. Tap each step.

Tap each point on the timeline.

Try it

Freeze web with docker pause web. Then check docker ps. What does STATUS say?

Your laptop~

  • No open hatches

Lunchboxes (containers)

  • webrunning
    from nginx:1.30-alpine
  • jobstopped
    from alpine:3.22

Frozen packs (images)

  • alpine:3.221 layers · 12.9MB · in use
  • nginx:1.30-alpine8 layers · 93.5MB · in use

2 containers (1 running), 2 images, 0 lockers.

Predict

job says Exited (0). Is that bad?

Pick one answer.

Watch

docker inspect with -f prints one detail. web's status is running. job's exit code is 0. Docker transcript: $ docker inspect -f '{{.State.Status}}' web running $ docker inspect -f '{{.State.ExitCode}}' job 0

Your laptop~

  • No open hatches

Lunchboxes (containers)

  • webrunning
    from nginx:1.30-alpine
  • jobstopped
    from alpine:3.22

Frozen packs (images)

  • alpine:3.221 layers · 12.9MB · in use
  • nginx:1.30-alpine8 layers · 93.5MB · in use

2 containers (1 running), 2 images, 0 lockers.

docker inspect reads the full label on a box. It holds every detail Docker knows. -f picks one line from it.

Check

True, or not quite? Swipe each card.

Swipe right for good, left for needs work. Or use the buttons.

1 / 5

docker ps shows stopped boxes too.

docker ps shows stopped boxes too.

You did it!

You can now read a container’s state and spot a broken one.

Go deeper (optional)

Rarer states: restarting (a restart policy brings it back), removing and dead. docker ps --filter status=exited lists only stopped boxes. docker stop asks nicely, then forces the box after 10 seconds.

Real rep (optional):

Real mission

  1. docker run -d --name web nginx:1.30-alpine
  2. docker stop web
  3. docker ps -a
  4. docker inspect -f '{{.State.Status}}' web
  5. docker rm web

0 of 5 steps done · Your ticks are saved.