:: Re: [DNG] Docker daemon logrotate
Forside
Slet denne besked
Besvar denne besked
Skribent: dng@d404.nl
Dato:  
Til: dng
Emne: Re: [DNG] Docker daemon logrotate
On 10-04-2024 05:01, Tom via Dng wrote:
>
>
>> On 9 Apr 2024, at 16:39, dng@??? wrote:
>>
>> Only setting "log-driver": "local" does not make logrotate work. A
>> more complete rule is:
>>
>> {
>>   "log-driver": "local",
>>   "log-opts": {
>>     "max-size": "10m",
>>     "max-file": "5"
>>   }
>> }
>
> Hmmm this is where I’m getting confused, because the docker docs says
> local log driver does rotation by default.
>
> https://docs.docker.com/config/containers/logging/configure/
>
>> and your are correct this is just the logging from within
>> containers.  The docker daemon self logs to daemon.log afaik.
>>
>> You have to restart the running containers for this change in
>> configuration to work.
>>
>> Grtz.
>>
>> Nick
>
> I guess I’ll have to configure debian logrotate config myself if the
> daemon doesn’t handle that. I’m kind of surprised that it’s not a more
> widespread issue. Does systemd/journald not require any logrotate.d
> config?
>
> Thanks
> Tom


My answers should have been a bit longer. According to the documentation:

"By default, no log-rotation is performed. As a result, log-files stored
by the default json-file logging driver logging driver can cause a
significant amount of disk space to be used for containers that generate
much output, which can lead to disk space exhaustion."

"log-driver":  "local" does do log-rotation according to the documentation:

"By default, the local driver preserves 100MB of log messages per
container and uses automatic compression to reduce the size on disk. The
100MB default value is based on a 20M default size for each file and a
default count of 5 for the number of such files (to account for log
rotation)."

Which in my case with easily 10 or more running containers fills up my
disk space really quickly but it should do log-rotation. If you want
some less disk use you set the log-opts. But you can set those log-opts
for (the default) json-file logdriver too according to
https://docs.docker.com/config/containers/logging/configure/

In /usr/lib/rsyslog/rsyslog-rotate you find a check for the running init

> #!/bin/sh
>
> if [ -d /run/systemd/system ]; then
>     systemctl kill -s HUP rsyslog.service
> else
>     invoke-rc.d rsyslog rotate > /dev/null
> fi


Grtz.

Nick