0

I have two docker containers running, where the diskspace is as follows:

user$ sudo docker system df
TYPE                TOTAL               ACTIVE              SIZE                RECLAIMABLE
Images              2                   1                   448.3MB             1.84kB (0%)
Containers          2                   2                   284.4MB             0B (0%)
Local Volumes       7                   2                   418.8kB             176.4kB (42%)
Build Cache         0                   0                   0B                  0B

If I check diskusage I get:

root:/var/lib/docker# du -ah --max-depth=1
45G     ./containers

What can I do to keep the containers (since I made a lot of configuration) but remove the obvious overhead?

Michael Hecht
  • 2,093
  • 6
  • 25
  • 37

2 Answers2

0

Please run the below command the clean the system as

  1. This will remove:
    • all stopped containers
    • all networks not used by at least one container
    • all dangling images
    • all dangling build cache
docker system prune -f 

And yes, you can remove the son file as well.

nischay goyal
  • 3,206
  • 12
  • 23
  • I just have the two containers which I want to keep definitely. My problem seems to be the unrestricted size of logfile. – Michael Hecht Mar 29 '20 at 19:52
  • When you run `docker system prune -f`, it will not remove the running containers or images and yes you can delete the logs file as well. – nischay goyal Mar 29 '20 at 20:22
0

You can use docker system prune -f, but, from my experience, it is not cleaning all that can be cleaned up.

For that, I've created a simple Docker image that does all the needed cleaning using only one command:

docker run -v /var/run/docker.sock:/var/run/docker.sock tikalci/tci-docker-cleanup:latest

For more details, see: https://github.com/TikalCI/tci-docker-cleanup

yorammi
  • 6,272
  • 1
  • 28
  • 34