-
-
Notifications
You must be signed in to change notification settings - Fork 511
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Remove created volumes when taking down a compose stack #690
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks for this! Could you please add a test for it? 🙏
@mdelapenya just added the tests. Thanks! |
@@ -157,6 +157,7 @@ func (d *dockerCompose) Down(ctx context.Context, opts ...StackDownOption) error | |||
options := stackDownOptions{ | |||
DownOptions: api.DownOptions{ | |||
Project: d.project, | |||
Volumes: true, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Hi @andyautida14 this will always remove the volumes. Do you think we can make it optional, creating a RemoveVolumes
functional option, exactly the same as in
testcontainers-go/compose_api.go
Lines 52 to 61 in e9fa657
// RemoveOrphans will cleanup containers that are not declared on the compose model but own the same labels | |
type RemoveOrphans bool | |
func (ro RemoveOrphans) applyToStackUp(o *stackUpOptions) { | |
o.RemoveOrphans = bool(ro) | |
} | |
func (ro RemoveOrphans) applyToStackDown(o *stackDownOptions) { | |
o.RemoveOrphans = bool(ro) | |
} |
That way users would be able to configure if they need to clean up the volumes they create
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yeah, sure. I'll try to find some time this week.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
BTW @andyautida14 please take a look at #650, which was merged after your PR: it moves the compose code to a separate module
@andyautida14 are you still interested in this PR? We'd like to include it, although there are missing pieces regarding the functional opts and the conflicts with current code. |
What does this PR do?
Cleans up orphaned volumes when taking down a Docker Compose stack.
Why is it important?
Cleaning up after your tests is important.
Related issues