2

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 and journald drivers make the logs available directly from docker-compose up and docker-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

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.