We are running a stack of Docker Swarm services and, according to our Privacy Policy, we have to keep logs only for the last 6 months, but no older. I was trying to achieve it through different logging drivers, but all of them (AFAIK) work only with max file-size, but not with times/dates.
The one solution that I came up with: use json-file
logging driver and then setup logrotate.d
with rotate 180
and daily
options.
The problem, however, is that json-file
logging driver doesn't disable standard Docker logging (I mean docker logs -f ...
or docker service logs -f ...
) which uses some internal Docker storage for logs, as per documentation:
Only the
json-file
andjournald
drivers make the logs available directly fromdocker-compose up
anddocker-compose logs
. Using any other driver does not print any logs.
In this case, the rotation will work for json-file
logs, but the "internal" logs will be still kept longer.
So, I wonder, how can one achieve time-based Docker log rotation?
0 Answers