0

My raspberrypi suddenly had no more free space.

By looking at the folder sizes with the following command:

sudo du -h --max-depth=3

I noticed that a docker folder eats an incredible amount of hard disk space. It's the folder

var/lib/docker/containers/*

The folder seems to contain some data for the current running docker containers. The first letters of the filename correspond to the docker container-ID. One folder seems to grow dramatically fast. After stopping the affected container and removed him, the related folder disappeared. So the folder seems to have belonged to it.

Problem solved.

I wonder now what the reason could be that this folder size increases so much. Further, I wonder what is the best way to not run into the same problem again later.

I could write a bash script which removes the related container at boot and run it again. Better ideas are very welcome.

Kadlu
  • 31
  • 1
  • 6
  • Does this answer your question? [How to remove old Docker containers](https://stackoverflow.com/questions/17236796/how-to-remove-old-docker-containers) – Nico Haase Sep 06 '22 at 15:06
  • `memory` != `hard disk space`, which is it (I assume hard drive space due to `du`)? Additionally, it really depends upon what is inside those docker containers. – Rogue Sep 06 '22 at 15:07
  • Thanks Rogue. Your right, I wrote wrong. Edited. – Kadlu Sep 07 '22 at 09:13

1 Answers1

0

The container ids are directories, so you can look inside to see what is using space in there. The two main reasons are:

  • Logs from stdout/stdere. These can be limited with added options. You can view these with docker logs.
  • Filesystem changes. The underlying image filesystem is not changed, so any writes trigger a copy-on-write to a directory within each container id. You can view these with docker diff.
BMitch
  • 231,797
  • 42
  • 475
  • 450
  • Thank you @BMitch. I checked the logs of the container and it looks like that the related piece of software (which is a python web socket) get's a connection break error message from time to time which creates a large amount of log messages. I guess I will try to limit these logs. Do you mean these options: ```--log-opt max-size=10m --log-opt max-file=5``` – Kadlu Sep 07 '22 at 09:22
  • @Kadlu yes. My preferred way is to put those options in the daemon.json to change the default for all new containers. https://stackoverflow.com/a/42510314/596285 – BMitch Sep 07 '22 at 09:31