Categories:

Docker clean up overlay

If you are having docker /var/lib/docker/overlay use almost of your storage, then you should ran some clean up code below.

From what I having on my 10Gb only VPS

# df -H
Filesystem              Size  Used Avail Use% Mounted on
udev                    238M     0  238M   0% /dev
tmpfs                    51M  5.7M   46M  12% /run
/dev/mapper/vg_jh-root  5.8G  5.5G  5.2M 100% /
tmpfs                   254M     0  254M   0% /dev/shm
tmpfs                   5.3M     0  5.3M   0% /run/lock
tmpfs                   254M     0  254M   0% /sys/fs/cgroup
/dev/vda1               487M  125M  333M  28% /boot
overlay                 5.8G  5.5G  5.2M 100% /var/lib/docker/overlay2/59983d9e0769f2ec06cf348b0a536c779cb3ad94c038ba3322239255e5965f37/merged
tmpfs                    51M     0   51M   0% /run/user/0

Code to run

docker volume rm $(docker volume ls -qf dangling=true)
docker system prune -a -f

What it does is try to remove other docker images and container, exclude current running container.

Photo by Sarah Dorweiler on Unsplash