JRehkemper.de

Docker Limit Log Size

Docker Logs can grow quite large. To prevent them from filling up your filesystem, you can instruct the Docker-Daemon to do a log rotation.

This is configured in the /etc/docker/daemon.json file. If it does not yet exist, you can safely create it.
The content should be as following:

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

This limits the size of your logs to a maximum of 10 MB.

For the new configuration to take affect, you need to reload the Docker-Service.

[tux@server]$ systemctl reload docker

All new Containers will receive the new limits, but existing ones will not. You will need to recreate them.

profile picture of the author

Jannik Rehkemper

I'm an professional Linux Administrator and Hobby Programmer. My training as an IT-Professional started in 2019 and ended in 2022. Since 2023 I'm working as an Linux Administrator.