Skip to content

Instantly share code, notes, and snippets.

@sirateck
sirateck / docker-container
Created February 9, 2021 23:22
Docker log rotation
#To create a new Logrotate config file for your Docker containers simply create a new file named /etc/logrotate.d/docker-container and put the following lines to it:
/var/lib/docker/containers/*/*.log {
rotate 7
daily
compress
missingok
delaycompress
copytruncate
}
# Once you have configured Logrotate for you Docker container you can test it with logrotate -fv /etc/logrotate.d/docker-container. You should get some output and a new log file with suffix [CONTAINER ID]-json.log.1 should be created. This file is compressed in next rotation cycle.