Skip to content

fix(docker): stop leaving anonymous volumes behind - #218

Merged
bryangingechen merged 1 commit into
masterfrom
fix/docker-leftovers
Oct 21, 2026
Merged

bryangingechen merged 1 commit into
masterfrom
fix/docker-leftovers

Conversation

@bryangingechen

Copy link
Copy Markdown
Contributor

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.sh removed its Postgres 18 and 17 containers with docker rm -f, which keeps their anonymous volumes: two Postgres data directories per run. Its cleanup now passes -v.
  • scripts/local_sanitize_backup.sh did 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 behind. Its cleanup now passes -v too.
  • docker-compose.yml: the redis service had no mount at /data, where the image declares a volume, so each new container got a new anonymous volume. docker compose down left it behind, and scripts/repo_check_compose.sh runs down before and after each run. Redis now keeps /data on 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

  • With a postgres container, docker rm -f leaves its volume whether or not the container was started with --rm, and docker rm -f -v doesn't.
  • scripts/test_download_s3_dump.sh passes (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.
  • Redis starts healthy with only the tmpfs at /data and can still save. The worker connects to it and beat starts. docker compose down leaves nothing.
  • bash scripts/repo_check_compose.sh passes, 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 only web, which doesn't depend on Redis, so it doesn't exercise the tmpfs itself.

🤖 Generated with Claude Code

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>
@bryangingechen
bryangingechen merged commit 78806ec into master Oct 21, 2026
8 checks passed
@bryangingechen
bryangingechen deleted the fix/docker-leftovers branch October 21, 2026 05:22
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant