1

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?

pkaramol
  • 16,451
  • 43
  • 149
  • 324

1 Answers1

0

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"}
}
MoiioM
  • 1,914
  • 1
  • 10
  • 16
  • I understand that in `/var/lib/docker/containers` there is info about logs. But what's in `/var/lib/docker/overlay2` ? – pkaramol Apr 15 '22 at 10:10
  • There is your images and containers layers. https://docs.docker.com/storage/storagedriver/overlayfs-driver/#image-and-container-layers-on-disk – MoiioM Apr 15 '22 at 10:18