- Advanced
- Data and disk
How it works
logging: options: max-size: "50m", max-file: "3" keeps at most three files of 50 MB and deletes the oldest. The local driver rotates and compresses by default (100 MB). log-opts in /etc/docker/daemon.json sets a default for every new container. New options only apply to containers created afterwards.
What breaks
One chatty container (debug logs left on, an error in a loop) fills the disk in hours; then the database cannot write, builds fail and other containers crash. docker system df does not count these files. driver: none saves the disk but leaves nothing to read when something goes wrong.
In compose.yaml
x-logging: &logging
driver: json-file
options:
max-size: "50m"
max-file: "3"
services:
api:
image: shop-api:4.2
logging: *logging
See it break, then fix it
Write the Dockerfile or the compose file, type the docker commands, and watch a simulated server run them through reboots, upgrades and traffic. Free to start.