Clean data of docker completely

Goal

Getting low on space, /var/lib/docker/aufs takes a lot of space. Need to remove all of them

root@CI:/var/lib/docker/aufs# df -h
Filesystem      Size  Used Avail Use% Mounted on
udev            992M     0  992M   0% /dev
tmpfs           200M  3.2M  197M   2% /run
/dev/xvda1       20G   19G  708M  97% /
tmpfs          1000M     0 1000M   0% /dev/shm
tmpfs           5.0M     0  5.0M   0% /run/lock
tmpfs          1000M     0 1000M   0% /sys/fs/cgroup
tmpfs           200M     0  200M   0% /run/user/112
tmpfs           200M     0  200M   0% /run/user/1000

root@CI:/var/lib/docker# du -shc *
16G    aufs
4.0K    containers
332K    image
60K    network
20K    plugins
4.0K    swarm
4.0K    tmp
4.0K    trust
60K    volumes
16G    total

Solution

docker rm $(docker ps -a -q)
docker rmi --force $(docker images -q)
docker system prune --force
systemctl stop docker
rm -rf /var/lib/docker/aufs
apt-get autoclean
apt-get autoremove
systemctl start docker

Last updated