Cleaning Up Safely

View saved

See what is using space

Docker stores images, containers, volumes, and build cache. Check usage before deleting.

docker system df

Remove stopped containers

Safe first step: delete containers that already exited.

docker container prune

Prune unused images and cache

Dangling images and build cache can grow large. Read the confirmation prompt carefully.

docker image prune
docker builder prune

Be careful with volumes

docker volume prune deletes unused volumes—and unused can still mean "data from a database you stopped." Prefer named volumes you recognize, and avoid pruning volumes unless you are sure.

# Broad cleanup of unused data EXCEPT volumes:
docker system prune

# Only when you accept deleting unused volumes too:
# docker system prune --volumes

Comments

One comment per signed-in account. Comments are saved with this page’s URL.