Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to clean up Docker

Tags:

docker

I've just noticed that I ran out of disk space on my laptop. Quite a lot is used by Docker as found by mate-disk-usage-analyzer:

Enter image description here

The docker/aufs/diff folder contains 152 folders ending in -removing.

I already ran the following commands to clean up

Kill all running containers: # docker kill $(docker ps -q)  Delete all stopped containers # docker rm $(docker ps -a -q)  Delete all images # docker rmi $(docker images -q)  Remove unused data # docker system prune  And some more # docker system prune -af 

But the screenshot was taken after I executed those commands.

What is docker/aufs/diff, why does it consume that much space and how do I clean it up?

I have Docker version 17.06.1-ce, build 874a737. It happened after a cleanup, so this is definitely still a problem.

like image 520
Martin Thoma Avatar asked Aug 21 '17 13:08

Martin Thoma


People also ask

How do I get rid of unused docker volumes?

Volumes are removed using the docker volume rm command. You can also use the docker volume prune command.


1 Answers

The following is a radical solution. IT DELETES ALL YOUR DOCKER STUFF. INCLUDING VOLUMES.

$ sudo su # service docker stop # cd /var/lib/docker # rm -rf * # service docker start 

See https://github.com/moby/moby/issues/22207#issuecomment-295754078 for details

It might not be /var/lib/docker

The docker location might be different in your case. You can use a disk usage analyzer (such as mate-disk-usage-analyzer) to find the folders which need most space.

See Where are Docker images stored on the host machine?

like image 50
Martin Thoma Avatar answered Oct 01 '22 02:10

Martin Thoma