简体   繁体   中英

Remove huge space occupied by docker folders

I have a VM on which I have been running (for a long time) a docker-compose stack.

Suddenly I started getting notifications about low disk space on my machine.

I noticed the following 2 directories occupying a disproportionally large amount of space

/var/lib/docker/containers

and

/var/lib/docker/overlay2

What is the type of information held there and how can I avoid the problem of disk depletion in the future consistently?

Docker save data for images and logs

For cleaning unused images and containers you can use the command docker system prune maybe with -a --volume options

For logs you can view response in this answer

Truncate logs

echo "" > $(docker inspect --format='{{.LogPath}}' <container_name_or_id>)

Setup logs rotation in /etc/docker/daemon.json

{
  "log-driver": "json-file",
  "log-opts": {"max-size": "10m", "max-file": "3"}
}

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM