3

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?

2
  • Bumping the thread. Still no solution for this question?
    – learner
    Apr 30 at 4:34
  • 1
    Unfortunately, no. We've eventually migrated to Kubernetes. Apr 30 at 10:10

0

You must log in to answer this question.

Browse other questions tagged .