Docker image prune cron on all Docker hosts #29
Labels
No Label
ai-changes-requested
ai-failed
ai-pr-opened
ai-reviewed
ai-reviewing
ai-working
infra-audit
monitoring
operations
proxmox
script
No Milestone
No project
No Assignees
2 Participants
Notifications
Due Date
No due date set.
Dependencies
No dependencies set.
Reference: cal/claude-home#29
Loading…
Reference in New Issue
Block a user
No description provided.
Delete Branch "%!s()"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
Context
The audit found stopped containers up to 2 years old and stale images across multiple VMs. Without periodic cleanup, Docker disk usage grows indefinitely — and stale images are a security surface.
Implementation
Add a monthly cron to each VM/host running Docker:
Hosts that need this
Tasks
--filter "until=720h"(30 days) won't remove images still used by running containers (it won't —prune -aonly removes unused images, and the filter adds an age gate)SRE Notes
docker volume prunewith--filter "label!=keep"allows marking critical volumes with akeeplabel to protect themLabels
infra-audit,operationsPR opened: #45
Created
ansible/playbooks/docker-prune.ymlfollowing the samehosts: <group>:... / become: truepattern asmask-avahi.yml. The playbook deploys/etc/cron.monthly/docker-pruneto all six Docker hosts (VMs 106, 110, 112, 115, 116, and manticore) with theansible.builtin.copymodule — idempotent, so re-running won't cause issues.Run from LXC 304:
ansible-playbook /opt/ansible/playbooks/docker-prune.yml