The one solution that I came up with: use
json-file logging driver and then setup
rotate 180 and
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:
journalddrivers make the logs available directly from
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?