Log management in Docker
·1 min
- Docker stores container logs in a local file and doesn’t rotate them by default.
- Add something like the following to /etc/docker/daemon.json to setup rotation.
{ "log-driver": "json-file", "log-opts": { "max-size": "10m", "max-file": "2" } }
- Do a
systemctl restart docker
to restart Docker daemon. - Also, this config only applies to new containers. So, recreate them by doing something like
docker-compose up -d --force-recreate foo
.
- Add something like the following to /etc/docker/daemon.json to setup rotation.
json-file
is the default log format and it might be a good idea to stick with it. For e.g., Promtail doesn’t work withlocal
.