Skip to content

Instantly share code, notes, and snippets.

@russianryebread
Last active December 7, 2022 10:09
Show Gist options
  • Star 7 You must be signed in to star a gist
  • Fork 2 You must be signed in to fork a gist
  • Save russianryebread/51c0bad2aaa92040ad69125cef92db77 to your computer and use it in GitHub Desktop.
Save russianryebread/51c0bad2aaa92040ad69125cef92db77 to your computer and use it in GitHub Desktop.
Docker Disk Management

See Used Space

docker system df         # Show docker disk usage, including space reclaimable by pruning

Reclaim Disk Space

docker container prune   # Remove all stopped containers
docker volume prune      # Remove all unused volumes
docker image prune       # Remove unused images
docker system prune      # All of the above, in this order: containers, volumes, images

Options

docker system prune --all     Remove all unused images not just dangling ones
docker system prune --force   Do not prompt for confirmation

Example Run

$ docker system df
TYPE                TOTAL               ACTIVE              SIZE                RECLAIMABLE
Images              21                  6                   7.111 GB            6.128 GB (86%)
Containers          6                   6                   4.324 MB            0 B (0%)
Local Volumes       2                   2                   227.3 MB            0 B (0%)

$ docker system prune
WARNING! This will remove:
    - all stopped containers
    - all volumes not used by at least one container
    - all networks not used by at least one container
    - all dangling images
Are you sure you want to continue? [y/N] y
Deleted Containers:
b196859d0baa3f3049263d5817249950329c4ed039c20e354737bd772b49ac49
...

Deleted Volumes:
1f31a17634329611e36045cba5b4a50e073aeda133f2962c83679fe8f9268467
...

Deleted Images:
deleted: sha256:7c0b8fb7832b03f7a6347e72327b05e563c73e5d5a25a7f186ae8edf8a6b4b88
...

Total reclaimed space: 1.711 GB
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment