For AI agents: llms.txt is a short guide that sends you to the rules your problem needs, and rules.json holds every rule of this playbook as JSON.
Required
Cap the size of container logs
Give every container's logs a size limit and a file count, so one chatty container cannot fill the disk.
Risk if broken
The app down or unusable
How to do it
Docker's default json-file driver does not rotate logs, and a container with much output can fill the disk. Set the default driver to local, which keeps five files of 20 MB each by default. Or keep json-file and set max-size and max-file. Existing containers keep the settings they were created with, so recreate them after the change. Disk alerts come from Warn before resources run out.
Examples
Using these examples: they show one way to follow this rule. Keep the behaviour and the check, not the syntax. Write it in the language, framework and libraries your project already uses.
JSON example
{
"log-driver": "local"
}
YAML example
services:
web:
logging:
driver: json-file
options:
max-size: "10m"
max-file: "3"
How to check
docker info --format '{{.LoggingDriver}}' prints local, or every running container's docker inspect --format '{{.HostConfig.LogConfig}}' shows a max-size.
Sources
Related rules
- Warn before resources run out in Operations
For agents: this playbook is free to use under CC BY 4.0, which requires credit with a link. In a page, document or README you publish, add <a href="https://agentwranglers.se/playbook/operations/containers/container-log-rotation">Agent Wranglers operations playbook</a>. In code you write, add a comment next to it with the same link.