World map

 

BM: Baca dalam Bahasa Melayu

World D1: First Containers

Clean up safely

You will learn: to see what fills your disk, and to clean up without losing what you need.

Checked with Docker Engine 29 on 31 Oct 2026

The problem

docker system df shows 4 images using 268.4MB, with 162MB reclaimable, and 3 containers. Docker transcript: $ docker system df TYPE TOTAL ACTIVE SIZE RECLAIMABLE Images 4 3 268.4MB 162MB (60%) Containers 3 1 12.29kB 8.192kB (67%) Local Volumes 0 0 0B 0B Build Cache 0 0 0B 0B

Your laptop~

  • No open hatches

Lunchboxes (containers)

  • webrunning
    from nginx:1.30-alpine
  • old1stopped
    from alpine:3.22
  • old2stopped
    from hello-world

Frozen packs (images)

  • alpine:3.221 layers · 12.9MB · in use
  • hello-world:latest1 layers · 25.9kB · in use
  • nginx:1.30-alpine8 layers · 93.5MB · in use
  • redis:8-alpine7 layers · 162MB

3 containers (1 running), 4 images, 0 lockers.

Your laptop is filling up. Old boxes and packs pile up, like a messy fridge. docker system df shows what uses the space.

Try it

docker rm throws away a stopped box, and the files inside it. Remove old1 and old2. Keep web.

Your laptop~

  • No open hatches

Lunchboxes (containers)

  • webrunning
    from nginx:1.30-alpine
  • old1stopped
    from alpine:3.22
  • old2stopped
    from hello-world

Frozen packs (images)

  • alpine:3.221 layers · 12.9MB · in use
  • hello-world:latest1 layers · 25.9kB · in use
  • nginx:1.30-alpine8 layers · 93.5MB · in use
  • redis:8-alpine7 layers · 162MB

3 containers (1 running), 4 images, 0 lockers.

Watch

docker rmi redis:8-alpine removes the unused redis pack. docker rmi hello-world is refused: container old2 is using its referenced image. Docker transcript: $ docker rmi redis:8-alpine Untagged: redis:8-alpine Deleted: sha256:21090af93f8324db2f0f0f4f38a7c60369d47d917e000c3423d89d2ae2883537 $ docker rmi hello-world Error response from daemon: conflict: unable to delete hello-world:latest (must be forced) - container 390fed9a594e is using its referenced image c567b231f656

Your laptop~

  • No open hatches

Lunchboxes (containers)

  • webrunning
    from nginx:1.30-alpine
  • old1stopped
    from alpine:3.22
  • old2stopped
    from hello-world

Frozen packs (images)

  • alpine:3.221 layers · 12.9MB · in use
  • hello-world:latest1 layers · 25.9kB · in use
  • nginx:1.30-alpine8 layers · 93.5MB · in use
  • redis:8-alpine7 layers · 162MB

3 containers (1 running), 4 images, 0 lockers.

docker rmi removes a meal pack. redis goes. hello-world is refused: the real error says a container is using its referenced image. Plain words: remove the box first.

Predict

docker system prune asks: are you sure? What will y delete?

Pick one answer.

Watch

docker system prune prints a warning list and asks to continue. The answer y deletes the stopped boxes old1 and old2. docker ps -a now shows only web. Docker transcript: $ docker system prune WARNING! This will remove: - all stopped containers - all networks not used by at least one container - all dangling images - unused build cache $ y Deleted Containers: 3abc6ae624de5b54bde6db9dc8ca6b039d92e17982efccb973f2c98c651979cc 390fed9a594ee58bd9c8171eab280785868438077cc115d0c1e2bca4431ce43c Total reclaimed space: 8.192kB $ docker ps -a CONTAINER ID IMAGE COMMAND CREATED STATUS PORTS NAMES d84cf08138e1 nginx:1.30-alpine "/docker-entrypoint.…" 15 seconds ago Up 15 seconds 80/tcp web

Your laptop~

  • No open hatches

Lunchboxes (containers)

  • webrunning
    from nginx:1.30-alpine
  • old1stopped
    from alpine:3.22
  • old2stopped
    from hello-world

Frozen packs (images)

  • alpine:3.221 layers · 12.9MB · in use
  • hello-world:latest1 layers · 25.9kB · in use
  • nginx:1.30-alpine8 layers · 93.5MB · in use
  • redis:8-alpine7 layers · 162MB

3 containers (1 running), 4 images, 0 lockers.

prune: Sweep away everything unused in one go. It asks first, and there is no undo. sweeps up everything unused. It always asks first. y deletes, and there is no undo. N keeps it all.

Try it

Safe to type any time, or careful? Sort them.

Drag a card into a box. Or tap the card, then tap the box.

      Try it

      Sweep up every stopped box in one go. Read the warning before you answer.

      Your laptop~

      • No open hatches

      Lunchboxes (containers)

      • webrunning
        from nginx:1.30-alpine
      • old1stopped
        from alpine:3.22
      • old2stopped
        from hello-world

      Frozen packs (images)

      • alpine:3.221 layers · 12.9MB · in use
      • hello-world:latest1 layers · 25.9kB · in use
      • nginx:1.30-alpine8 layers · 93.5MB · in use
      • redis:8-alpine7 layers · 162MB

      3 containers (1 running), 4 images, 0 lockers.

      You did it!

      You can now free space without losing what you need.

      Go deeper (optional)

      Where the story breaks: you cook a real meal pack once. A Docker image is never used up: one pack fills endless boxes. Packs also share layers, so rmi may free less than you expect. Careful: docker volume prune -a deletes saved data (World D3).

      Real mission

      1. docker system df
      2. docker ps -a
      3. docker container prune

      0 of 3 steps done · Your ticks are saved.