Stop leaving the volume-init container behind - #121
Merged
Merged
Conversation
… run `docker compose run --rm` removes the container it was asked to run and nothing else. Every service that writes to the cache volume pulls in volume-init through depends_on to get the directories created and chowned, so each task left a completed labelsync-volume-init-1 behind — harmless, but it accumulates one stale container per project that only ever surfaces in `docker ps -a`. The internal dc task is the single point every compose invocation passes through, so one defer there covers dc:run:*, dc:build, dc:shell and the lint, docs, markdown and demo taskfiles that call into it. Task runs deferred commands when the task ends regardless of its result, so a failing test tears the container down too. The teardown is the same defer the demo:record task already uses for the socket proxy.
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.
Summary
defer: docker compose rm --stop --force volume-initon the internaldctask, which every compose invocation passes through — so it coversdc:run:*,dc:build,dc:shelland the lint, docs, markdown and demo taskfiles that call into it.Why
docker compose run --rmremoves the container it was asked to run and nothing else. Every service that writes to the cache volume pulls involume-initthroughdepends_on, so each task left a completedlabelsync-volume-init-1behind — harmless, but one stale container per project accumulating where onlydocker ps -ashows it.Ported from specsnl/specs-cli#147.
Verified locally
task checkallgreen, anddocker ps -a --filter name=volume-initis clean afterwards for this checkout's compose project — where an unpatched checkout of the same repository still leaves its container behind.