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 anonymous volumes when using run --rm. #3756
Conversation
a667b6b
to
f51086f
Compare
Thanks! LGTM ping @dnephin |
if volumes is None: | ||
volumesBefore = 0 | ||
else: | ||
volumesBefore = len(volumes) |
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.
I don't think this is the right way to test this. It's too prone to failure. It assumes the engine being used is not in use by anything else, which is not a good assumption. The test could also pass if no volume was created, even though the remove didn't work.
A better way to test this would be to inspect the container that is created, get the volume id, and assert that the volume doesn't exist when the container exits. It's a little more involved to write, but you can do it with start_process()
and wait_on_process()
.
You'll need to run a non-terminating command instead of /bin/true
.
start_process(...)
wait_on_condition(ContainerCountCondition(self.project, 1))
container, = self.project.get_service('test').containers(...)
self.dispatch(["stop"])
# inspect volume by id and assert a not found error
Done. Do you want me to squash the commits? |
@nkovacs yes please! |
Named volumes will not be removed. This is consistent with the behavior of docker run --rm. Fixes docker#2419, docker#3611 Signed-off-by: Nikola Kovacs <nikola.kovacs@gmail.com>
0fe83ce
to
958758f
Compare
Hi, |
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.
Thank you!
Named volumes will not be removed.
This is consistent with the behavior of docker run --rm.
Fixes #2419, #3611