-
Notifications
You must be signed in to change notification settings - Fork 229
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
Fix Docker image deletion when using remove_images: true #361
Conversation
@@ -35,7 +35,7 @@ def parse_image_id(output) | |||
|
|||
def remove_image(state) | |||
image_id = state[:image_id] | |||
docker_command("rmi #{image_id}") | |||
run_command("docker ps -a | grep -q #{image_id} && echo 'Can not delete such image; It is being used by running container/s' || docker rmi #{image_id}") |
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.
Could we implement this using a new method inside this helper instead of in line with bash? I'd rather raise an exception and allow test kitchen to handle the exception instead of writing a message to stdout.
Something more like this?
def image_in_use?
# determine if image is in use with a running container
end
def remove_image(state)
image_id = state[:image_id]
raise "Can not delete image #{state[:image_id]}. It is being used by a running container." if image_in_use?
docker_command("rmi #{image_id}")
end
Hi @jeffreycoe, sorry I didn't have time to add the changes you requested before, but I think this issue is still persisting. Kind regards, |
@rshad - Thanks for the response. Will you be updating this PR with these changes, or can this PR be closed out and be addressed at a later time? |
Sorry, I am not working with kitchen since many months ago and I don't think that I'll be adding the related changes soon. Kind regards, Rshad |
@rshad Ok - I'll close this PR for now, and we can revisit this at a later time. Thanks! |
Hi all!
This PR resolves #360
My fix is based on the idea of deleting the target Docker image only if it's not being used by an existing container, in other cases Kitchen will print an INFO message.
Note
: I first merged the fix of #356 from the corresponding fork branch: paulcalabro:fix-ip-address-issue.Kr,
Rshad