providers/docker: be more lenient about deleting built image

This commit is contained in:
Mitchell Hashimoto 2014-04-28 09:36:55 -07:00
parent 8ed5351dd1
commit d7ecd99e2e
3 changed files with 10 additions and 1 deletions

View File

@ -26,7 +26,10 @@ module VagrantPlugins
if image if image
machine.ui.output(I18n.t("docker_provider.build_image_destroy")) machine.ui.output(I18n.t("docker_provider.build_image_destroy"))
machine.provider.driver.rmi(image) if !machine.provider.driver.rmi(image)
machine.ui.detail(I18n.t(
"docker_provider.build_image_destroy_in_use"))
end
end end
if image_file && image_file.file? if image_file && image_file.file?

View File

@ -104,7 +104,9 @@ module VagrantPlugins
def rmi(id) def rmi(id)
execute('docker', 'rmi', id) execute('docker', 'rmi', id)
return true
rescue Exception => e rescue Exception => e
return false if e.to_s.include?("is using it")
raise if !e.to_s.include?("No such image") raise if !e.to_s.include?("No such image")
end end

View File

@ -4,6 +4,10 @@ en:
Image is already built from the Dockerfile. `vagrant reload` to rebuild. Image is already built from the Dockerfile. `vagrant reload` to rebuild.
build_image_destroy: |- build_image_destroy: |-
Removing built image... Removing built image...
build_image_destroy_in_use: |-
Build image couldn't be destroyed because the image is in use. The
image must be destroyed manually in the future if you want to remove
it.
build_image_invalid: |- build_image_invalid: |-
Build image no longer exists. Rebuilding... Build image no longer exists. Rebuilding...
building: |- building: |-