Docker - free space after deleting all images and containers

I deleted all 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

but I noticed that inside /var/lib/docker

still about 15 GB.
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:

  • How can I free this space?

  • Is it safe to delete things inside /var/lib/docker?

+2
source share
3 answers

Try (from docker 1.13):

docker system df

It shows you the size:

  • Images
  • Containers
  • Local volumes

and delete the local volumes using:

docker volume prune

For older Dockers, try:

docker volume rm $(docker volume ls -q)
+3
source

For my current version of dockers (1.12.1 for client and server) the way to delete all volumes is:

docker volume rm $(docker volume ls -q)

but the following is safer: (thanks Matt for your comment)

$(docker volume ls -qf dangling=true)

: 1.13.0 (2017-01-18) :

$ docker system prune
$ docker container prune
$ docker image prune
$ docker volume prune
$ docker network prune

Changelog: docker system df prune , docker {container,image,volume,network} prune # 26108 # 27525/# 27525

+2

docker volume, :

12G./volumes

, . / . . .

If you use the latest version of docker, you can find docs commands related to volumes for more detailed information (list / delete / create volumes for example), for an older version of dockers, you can refer to this script on github to clean volumes.

Hope this can be useful :-)

0
source

Source: https://habr.com/ru/post/1016728/


All Articles