dockerdiskspace

Free up space after removing all images & containers


I have deleted all the images/containers

ubuntu@ubuntu:/var/lib/docker$ docker images
REPOSITORY          TAG                 IMAGE ID            CREATED             SIZE
ubuntu@ubuntu:/var/lib/docker$ docker ps -a
CONTAINER ID        IMAGE               COMMAND             CREATED             STATUS              PORTS               NAMES

I notice that there is still about 15GB used inside /var/lib/docker

ubuntu@ubuntu:/var/lib/docker$ sudo du --max-depth=1 -h .
12G     ./volumes
104K    ./aufs
4,0K    ./containers
1,3M    ./image
4,0K    ./trust
4,0K    ./swarm
2,6G    ./tmp
108K    ./network
15G     .

Questions:

  1. How can I free up this space?

  2. Is it safe to remove things inside /var/lib/docker?


Solution

  • Try (from docker 1.13):

    docker system df
    

    it shows you size of:

    and remove local volumes using:

    docker volume prune
    

    For older Dockers try:

    docker volume rm $(docker volume ls -q)