Overlay2 Folder

I was trying to get a few containers to work and tried many many failed configs over the course of a week until I got what I wanted. This created a very bloated Overlay2 folder and has left me with only 50Gb left on my system drive. How can I clean it up without damaging my good containers (running and stopped)?

Keep it simple and do not touch overlay2 manually.

Safe way to free space without breaking containers:

  1. Check what Docker sees as unused
docker system df
  1. Remove stopped containers only (safe)
docker container prune
  1. Remove unused images (safe)
docker image prune

(Optional, still safe – removes images not used by any container)

docker image prune -a
  1. Biggest win – clean build cache (very safe)
docker builder prune --all
  1. Verify space
df -h
docker system df

Do NOT delete anything inside /var/lib/docker/overlay2 by hand.
Docker prune commands only remove layers not referenced by running or stopped containers, so your good containers stay intact.