providers/docker: smarter about setting ID to nil for machine
This commit is contained in:
parent
d526dd54fe
commit
b26ecb0150
|
@ -143,6 +143,7 @@ module VagrantPlugins
|
||||||
b.use Call, IsState, :not_created do |env, b2|
|
b.use Call, IsState, :not_created do |env, b2|
|
||||||
if env[:result]
|
if env[:result]
|
||||||
b2.use Message, I18n.t("docker_provider.messages.not_created")
|
b2.use Message, I18n.t("docker_provider.messages.not_created")
|
||||||
|
b2.use Destroy
|
||||||
next
|
next
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
|
@ -7,20 +7,25 @@ module VagrantPlugins
|
||||||
end
|
end
|
||||||
|
|
||||||
def call(env)
|
def call(env)
|
||||||
env[:ui].info I18n.t("docker_provider.messages.destroying")
|
|
||||||
|
|
||||||
machine = env[:machine]
|
machine = env[:machine]
|
||||||
driver = machine.provider.driver
|
|
||||||
|
|
||||||
# If we have a build image, store that
|
# If the container actually exists, destroy it
|
||||||
image_file = machine.data_dir.join("docker_build_image")
|
if machine.state.id != :not_created
|
||||||
image = nil
|
driver = machine.provider.driver
|
||||||
if image_file.file?
|
|
||||||
image = image_file.read.chomp
|
# If we have a build image, store that
|
||||||
|
image_file = machine.data_dir.join("docker_build_image")
|
||||||
|
image = nil
|
||||||
|
if image_file.file?
|
||||||
|
image = image_file.read.chomp
|
||||||
|
end
|
||||||
|
env[:build_image] = image
|
||||||
|
|
||||||
|
env[:ui].info I18n.t("docker_provider.messages.destroying")
|
||||||
|
driver.rm(machine.id)
|
||||||
end
|
end
|
||||||
env[:build_image] = image
|
|
||||||
|
|
||||||
driver.rm(machine.id)
|
# Otherwise, always make sure we remove the ID
|
||||||
machine.id = nil
|
machine.id = nil
|
||||||
|
|
||||||
@app.call(env)
|
@app.call(env)
|
||||||
|
|
Loading…
Reference in New Issue