I've been monitoring my VMs and noticed that their disk usage spiked to nearly 100%. After digging into it, it turns out that Docker logs in the /var directory were taking up way too much space. I cleaned things up using some commands to truncate the logs and adjust the journal size, but I'm curious about what caused the log growth in the first place. The last major change I made was updating Docker to version 29, which broke my Portainer setup. To mitigate this in the future, I also modified the Docker API version. Any advice on managing Docker logs and preventing this issue again?
1 Answer
You should configure Docker's logging driver in the /etc/docker/daemon.json file. Set up the log options like this: {"log-driver": "json-file", "log-opts": {"max-size": "20m", "max-file": "5", "compress": "true"}}. After that, restart the Docker service. This way, Docker will limit the log size and manage old log files for you.

Just keep in mind that existing containers won't automatically use this new logging configuration. You might need to recreate or update them for the changes to take effect.