Home > Blockchain >  Remove huge space occupied by docker folders
Remove huge space occupied by docker folders

Time:04-16

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?

CodePudding user response:

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"}
}
  • Related