Repository navigation
feat(admin): automatic Docker cleanup on every node - #262
Merged
Merged
Conversation
- Scheduler on the leader (default: daily 03:00 Europe/Paris), emergency cleanup when a node's Docker disk exceeds the alert threshold (85%). - Build cache: buildx prune per builder + buildctl prune inside running buildx_buildkit_* containers, older than the retention (24h). - Images: unused images older than the retention, old deployment images beyond the N kept per project (3). Never images used by a container (running or stopped), never df-*:latest, never volumes/containers, never image rm -f. - Each successful deploy tags df-<id>:r<ts> so rollback images survive. - Admin page: tiles (auto switch, clean now with dry-run + confirmation, history, log rotation, per-node disk), details in modals. - Optional --log-opt rotation for DevForge-launched containers; daemon.json never edited (snippet shown). - Retires the broken legacy /etc/cron.d/devforge-disk-guard when the host is visible; DOCKER_CONFIG fallback for read-only ~/.docker.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Why
On 2026-10-21 the NAS Docker disk (
/media/Docker, 477 GB btrfs) filled to 100%: about 425 GB of images and build cache from DevForge builds, and Docker stopped. The old host cron/etc/cron.d/devforge-disk-guard(pre-v2) had been failing every 10 minutes since August, because dcron rejects itsrootfield and variable lines.What
Scheduler (leader, in-process)
Europe/Pariswhatever the host timezone is), 24 h retention, 3 images kept per project, disk alert at 85 %.POST /internal/execon workers. Only one cleanup runs at a time.Scope
docker buildx prune --builder <b> --filter until=<ret>for each registered builder, plusbuildctl prune --keep-duration <ret>inside each runningbuildx_buildkit_*container. The second covers builders that aren't registered for the user (ZimaOS).df-<id>:r<ts>, so rollback images exist and can be counted.df-*:latest.system prune,container prune,image rm -f. Without-f, Docker itself refuses to remove an image that is in use.Admin page (
/app/admin?tab=docker, plus a hub tile)Logs
--log-opt max-size/max-filefor containers launched by DevForge. Off by default, and refused if a node's logging driver isn't json-file or local.daemon.jsonis never edited; the modal shows the snippet to apply by hand.Environment
DOCKER_CONFIG=/tmp/devforge-docker-gcwhen~/.dockeris read-only./etc/cron.d/devforge-disk-guardis moved (not deleted) to/DATA/.devforge/state/when the leader starts, if the host filesystem is visible. If DevForge runs in a container, the node modal says so instead.API
GET/PUT /api/v1/admin/docker-gcGET /api/v1/admin/docker-gc/nodesPOST /api/v1/admin/docker-gc/preview(dry run)POST /api/v1/admin/docker-gc/runwith{confirm:true}GET /api/v1/admin/docker-gc/runsAll are admin-only.
Tests
docker_gc_tests.rs: retention, keep-N per project, images of running and stopped containers protected,:latestprotected, unsafe refs skipped, scripts never touch volumes or containers (no-f), inventory /buildx ls/ sizes / cleanup output parsing, schedule and cron validation, emergency cooldown, legacy cron moved rather than deleted.docker.rs:--log-optarguments.lib.rs: the rollback tag.formatBytes.Docs:
docs/DOCKER_GC.md.