Repository navigation
feat: optionally remove old Dokploy images on web server update - #34
Merged
Merged
Conversation
The update dialog gets a switch "Remove old Dokploy images, keep the last N" (N = 3, 4 or 5). The choice is stored on the dokploy service as DOKPLOY_KEEP_IMAGES, so it survives restarts and later manual updates. Cleanup runs when the new Dokploy container starts, because the update replaces the container that started it (stop-first). It removes exited dokploy task containers that pin old images, then the images beyond the newest N of the fork and official repositories. Nothing is forced: images used by running or foreign containers are left alone. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
A button under the cleanup switch shows how many Dokploy images are on the host and their total size. Its popover lists each image with fork version, build date, size and the space deleting it frees, and marks which ones stay and which ones are deleted for the chosen keep count. A pending update counts as the newest image. Images used by other containers are shown as kept. settings.getDokployImages reads the images, their unique sizes from `docker system df -v` and the containers that use them. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
settings.getDokployImageKeepCount and settings.getDokployImages only read Docker state, so they are "read" procedures. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
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.
What
The Web Server Update dialog gets a new switch: Remove old Dokploy images, keep the last [3|4|5].
Every web server update pulls a new ~4.4 GB image, and old ones were never removed. With the switch on, only the newest N Dokploy images stay on the host.
How
settings.updateServer({ keepImages })and stored on thedokployservice asDOKPLOY_KEEP_IMAGES(0= off). It survives restarts and later manualdocker service updateruns.server.ts). It can't run from the update request itself, because the update replaces the container that issued it (stop-first).getDokployImageCleanupCommand(keep):dokploy/dokploy, sorts them by creation time, keeps the newest N;dokployswarm service that pin it (swarm keeps up to 5 task containers);settings.getDokployImageKeepCount(admin) so the dialog shows the saved value. Until it loads, the update leaves the setting unchanged.Image list and preview
Under the switch, a button (
HardDriveicon) shows how many Dokploy images are on the host and their total size, e.g.3 images · 13.36 GB. The popover lists each image, newest first, with:docker system df -v);A pending update is shown as a New build row and counts as one of the kept images, because the cleanup runs after it. A footer sums what gets deleted ("Deletes 1 image, frees about 4.11 GB"). The data comes from the new admin query
settings.getDokployImages; the marking is a pure client function (planDokployImageCleanup) that mirrors the shell script.Checks
vitest __test__/settings/: 86 passed (incl.dokploy-image-plan.test.tsand image list parsing) (newdokploy-image-cleanup.test.tsplus router cases for passing, rejecting and turning off the keep count).tsc --noEmitinapps/dokployandpackages/server; biome clean.dokploytask container, left one used by a foreign container alone.sort,awk,tail,dockerexist in the Dokploy image.getDokployImagesrun live against local Docker (6 test images, multi-tag, exited task and foreign containers, image without Env); output formats checked read-only on dev.🤖 Generated with Claude Code