rs clean — Docker cleanup and log limits
What rs clean deletes and what not, how to limit Docker logs, rotation and journald.
rs clean shows what takes space and cleans step by step — each step asks. --report — report only, --yes — no questions, safe steps only.
What is deleted and what is not
| Step | Default | Risk |
|---|---|---|
| Dangling images (untagged layers) | yes | none: leftovers of old versions |
| Build cache | yes | the next docker build takes longer |
| Stopped containers | no | they can no longer be started with docker start; RunStack containers are not touched |
| Unused images | no | downloaded again when needed |
| Empty logs over 100 MB | no | log history is lost; containers keep running |
| Log limit in daemon.json | yes | — |
| Shrink journald to 500 MB | no | old system logs are lost |
Volumes are never deleted — databases and app files live there. The script only lists unused ones; check and remove by hand: docker volume rm <name>.
Docker log limit
By default the json-file driver writes container logs without a limit — one chatty container can fill the disk. The limit for all new containers is in /etc/docker/daemon.json (rs clean adds it, keeping your other settings):
{
"log-driver": "json-file",
"log-opts": { "max-size": "10m", "max-file": "3" }
}
It applies after systemctl restart docker (running containers restart) and only to new or recreated containers: docker compose up -d --force-recreate in the project directory. For one service — in its compose file:
logging:
driver: json-file
options: { max-size: "10m", max-file: "5" }
RunStack services have this limit from the start.
The system journal
Limit journald permanently: SystemMaxUse=500M in /etc/systemd/journald.conf, then systemctl restart systemd-journald. Once: journalctl --vacuum-size=500M.
If the disk fills up again
rs info diskanddu -xh / --max-depth=2 | sort -h | tail— what grows.- Backups on the same disk are a common cause; keep them elsewhere.
- App logs in
/var/log— check logrotate.
