Repository navigation
fix(docker): stop leaving anonymous volumes behind - #218
Merged
Merged
Conversation
Three places left a Docker volume on the machine each time they ran, and nothing referenced it afterwards: - scripts/test_download_s3_dump.sh removed its Postgres 18 and 17 containers with `docker rm -f`, which keeps their anonymous volumes: two Postgres data directories per run. - scripts/local_sanitize_backup.sh does the same. --rm deletes the volume only when the container stops on its own, so each run left a full copy of the restored database. - Compose's redis service had no mount at /data, where the image declares a volume, so each new container got a new anonymous one, which `docker compose down` (as scripts/repo_check_compose.sh runs it) left behind. Redis now keeps /data on a tmpfs: it holds only the broker's queue and the app's short-lived keys, which it can lose, and it was already empty after each `down`. Tested: test_download_s3_dump.sh passes, and leaves Docker's volumes, networks and containers as it found them. So does local_sanitize_backup.sh when its restore fails, after the container has started. Redis starts healthy with only the tmpfs at /data, and `docker compose down` leaves nothing. 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.
Motivation
Three places left a Docker volume on the developer's machine each time they ran, and nothing referenced it afterwards. On one machine, about 30 had piled up, including six full copies of a restored database at about 800 MB each.
What changes
scripts/test_download_s3_dump.shremoved its Postgres 18 and 17 containers withdocker rm -f, which keeps their anonymous volumes: two Postgres data directories per run. Its cleanup now passes-v.scripts/local_sanitize_backup.shdid the same.--rmdeletes the volume only when the container stops on its own, so each run left a full copy of the restored database behind. Its cleanup now passes-vtoo.docker-compose.yml: theredisservice had no mount at/data, where the image declares a volume, so each new container got a new anonymous volume.docker compose downleft it behind, andscripts/repo_check_compose.shrunsdownbefore and after each run. Redis now keeps/dataon a tmpfs.User-visible effects
None in the app. Redis's data was already gone after each
docker compose down. With the tmpfs it's also gone when the container is recreated or restarted. Redis holds only the broker's queue and the app's short-lived keys, which it can lose; the results backend is the database.Testing
postgrescontainer,docker rm -fleaves its volume whether or not the container was started with--rm, anddocker rm -f -vdoesn't.scripts/test_download_s3_dump.shpasses (11 checks), and leaves Docker's volumes, networks and containers as it found them.scripts/local_sanitize_backup.sh, given a file that isn't a dump, starts its container, fails at the restore, and leaves nothing behind./dataand can still save. The worker connects to it and beat starts.docker compose downleaves nothing.bash scripts/repo_check_compose.shpasses, skipping only step 2, the GraphQL validation, which runs on the host (core 139, syncer 543, analyzer 606, api 28, zulip_bot 350, console 96, site_analytics 81 tests). It starts onlyweb, which doesn't depend on Redis, so it doesn't exercise the tmpfs itself.🤖 Generated with Claude Code