providers/docker: rebuild image if it doesn't exist
This commit is contained in:
parent
d837086572
commit
1c3ee6ffa3
|
@ -25,6 +25,12 @@ module VagrantPlugins
|
|||
image = image_file.read.chomp
|
||||
end
|
||||
|
||||
# Verify the image exists if we have one
|
||||
if image && !machine.provider.driver.image?(image)
|
||||
machine.ui.output(I18n.t("docker_provider.build_image_invalid"))
|
||||
image = nil
|
||||
end
|
||||
|
||||
# If we have no image or we're rebuilding, we rebuild
|
||||
if !image || env[:build_rebuild]
|
||||
# Build it
|
||||
|
|
|
@ -63,6 +63,11 @@ module VagrantPlugins
|
|||
result =~ /^#{Regexp.escape cid}$/
|
||||
end
|
||||
|
||||
def image?(id)
|
||||
result = execute('docker', 'images', '-q').to_s
|
||||
result =~ /^#{Regexp.escape(id)}$/
|
||||
end
|
||||
|
||||
def running?(cid)
|
||||
result = execute('docker', 'ps', '-q', '--no-trunc')
|
||||
result =~ /^#{Regexp.escape cid}$/m
|
||||
|
|
|
@ -4,6 +4,8 @@ en:
|
|||
Image is already built from the Dockerfile. `vagrant reload` to rebuild.
|
||||
build_image_destroy: |-
|
||||
Removing built image...
|
||||
build_image_invalid: |-
|
||||
Build image no longer exists. Rebuilding...
|
||||
building: |-
|
||||
Building the container from a Dockerfile...
|
||||
creating: |-
|
||||
|
|
Loading…
Reference in New Issue