Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

safe way to clean /var/lib/docker

I've got a django project with docker and i've discovered that my docker folder eating space abnormally.

here is console:

[root@1507191 django]# docker images -a
REPOSITORY             TAG              IMAGE ID       CREATED        SIZE
django-web             latest           1ed6e146c8f1   12 days ago    5.98GB
postgres               13.9-alpine      8e750948d39a   6 months ago   238MB
selenium/node-chrome   4.7.2-20221219   de92c5f8374c   7 months ago   1.3GB
selenium/hub           4.7.2-20221219   cfb1e9a75197   7 months ago   420MB
nginx                  1.13-alpine      ebe2c7c61055   5 years ago    18MB

So docker folder should takes about 8GB but it takes 14GB:

[root@1507191 django]# pwd
/var/lib/docker
[root@1507191 django]# sudo du -d 1
4   ./swarm
28  ./volumes
9980    ./image
13028   ./buildkit
16  ./plugins
312 ./containers
13920928    ./overlay2
4   ./runtimes
80  ./network
4   ./tmp
13944392    .

So the question is: how to clean it safe?

like image 776
Yuretz Avatar asked Oct 31 '25 05:10

Yuretz


1 Answers

To clean Docker from unused stuff run one command docker system prune --all --volumes.

It will delete followings:

docker system prune -a --volumes
WARNING! This will remove:
  - all stopped containers
  - all networks not used by at least one container
  - all volumes not used by at least one container
  - all images without at least one container associated to them
  - all build cache
like image 95
Justinas Avatar answered Nov 02 '25 19:11

Justinas