It reads /etc/docker/daemon.json and greps two keys out of it, "log-driver" and "max-size". The driver decides the branch, and an absent "log-driver" is treated as json-file, which is Docker's own default. On json-file the presence of a "max-size" value anywhere in the file is the whole test: with one the check PASSes, without one it WARNs. Any other driver value PASSes outright, on the assumption that the driver handles its own rotation.
Runs whenever the docker binary exists; no daemon access or root needed, since it only reads /etc/docker/daemon.json. It inspects the daemon-wide default log driver and max-size. With the default json-file driver and no max-size it WARNs; with any other driver it PASSes on the assumption that driver handles its own retention.
Known accuracy issue: per-container settings are invisible. A host that caps logs on every container with --log-opt max-size=10m (or a Compose logging: block) still gets a WARN, and conversely a daemon default of max-size does not prove a container has not overridden it. This is the known issue flagged at the top of this page.
| Result | When | What it means |
|---|---|---|
| SKIP | Docker not installed | Nothing was checked. With no docker binary on the host, no log driver setting was read at all. |
| PASS | json-file with max-size set | The daemon default caps container logs and rotates them, so they cannot grow without bound. |
| WARN | json-file without max-size | The daemon default puts no ceiling on container logs, so one chatty container can fill the disk. Per-container caps are invisible to this check. |
| PASS | Other driver (local, journald, syslog, ...) | Logging is handed to a different driver and the check assumes that driver enforces its own retention. Confirm that on the receiving end. |
Docker's default json-file driver has no size limit. A chatty or compromised container fills the disk, which stops the daemon, databases and SSH logins on the host (availability, and a denial-of-service vector). Docker docs recommend the local driver (which rotates by default) or explicit max-size/max-file. CIS Docker 2.13 covers centralised logging.
- Per-container
--log-opt max-size=10m(Composelogging: options:) is not read; hosts that cap logs per service get a false WARN. Confirm withdocker inspect -f '{{.HostConfig.LogConfig}}' <name>. - Changing
daemon.jsononly affects new containers; existing ones keep their original LogConfig until recreated. daemon.jsonunreadable → both greps are empty → WARN even if configured.
Set a capped default in daemon.json
Merge this into the keys already in
/etc/docker/daemon.json. Thelocaldriver rotates on its own; to keepjson-file, use the samelog-optswith"log-driver": "json-file". Both values must be strings.json { "log-driver": "local", "log-opts": { "max-size": "20m", "max-file": "5" }}Validate and restart Docker
An invalid
daemon.jsonstops the daemon from starting, so check it parses first.sh python3 -m json.tool /etc/docker/daemon.json >/dev/null && sudo systemctl restart dockerRecreate the containers
Existing containers keep the log configuration they were created with, so the new default only applies once they are recreated. Shipping logs to journald, syslog or Loki instead is the other route.
sh docker compose up -d --force-recreate
# The daemon default (what the check reads):sudo cat /etc/docker/daemon.jsondocker info --format 'driver={{.LoggingDriver}}'# What each running container actually uses - the part the check cannot see:docker inspect -f '{{.Name}} {{.HostConfig.LogConfig.Type}} {{.HostConfig.LogConfig.Config}}' $(docker ps -q)# expected: a max-size on every json-file container# And the ground truth - how big the log files actually are:# (sh -c, because the directory is root-only and the glob must expand as root)sudo sh -c 'du -sh /var/lib/docker/containers/*/*-json.log' | sort -h | tail -5- The known false positive above. Confirm with the
docker inspectcommand; if every container carries amax-size, record it. Setting the daemon-wide default as well is the cleanest resolution, and it protects containers created later that forget the flag. - The check greps for
"max-size"anywhere in the file, so a syntax problem is the likely cause.max-sizebelongs insidelog-opts, and its value must be a string ("10m", not10m). Validate withpython3 -m json.tool /etc/docker/daemon.json; an invaliddaemon.jsonalso stops the daemon from starting. - Log configuration is fixed at container creation. Recreate them (
docker compose up -d --force-recreate) for the new default to apply. - The check assumes
journald,syslog,localand remote drivers manage their own retention. Verify that assumption on the receiving end:journaldobeysSystemMaxUseinjournald.conf, and a remote collector has its own policy. Thelocaldriver does rotate by default;json-filedoes not. - Truncate safely with
sudo sh -c 'truncate -s 0 /var/lib/docker/containers/*/*-json.log'(deleting the file leaves the daemon writing to a removed inode), then fix the default and recreate the containers. Thesh -cmatters: the containers directory is readable only by root, so a plainsudo truncatewith the glob fails because your own shell cannot expand it.
