providers/docker: more robustly detect built image [GH-4598]

This commit is contained in:
Mitchell Hashimoto 2014-10-21 17:44:48 -07:00
parent 945b63f033
commit e749eaa039
2 changed files with 6 additions and 4 deletions

View File

@ -7,6 +7,8 @@ BUG FIXES:
- providers/docker: Nicer error if package is called. [GH-4595]
- providers/docker: Host IP restriction is forwarded through. [GH-4505]
- providers/docker: Protocol is now honored in direct `ports settings.
- providers/docker: Images built using `build\_dir` will more robustly
capture the final image. [GH-4598]
- providers/virtualbox: Show a human-friendly error if VirtualBox didn't
clean up an existing VM. [GH-4681]
- provisioners/docker: Search for docker binary in multiple places. [GH-4580]

View File

@ -18,15 +18,15 @@ module VagrantPlugins
args = Array(opts[:extra_args])
args << dir
result = execute('docker', 'build', *args)
regexp = /Successfully built (.+)$/i
match = regexp.match(result)
if !match
matches = result.scan(/Successfully built (.+)$/i)
if matches.empty?
# This will cause a stack trace in Vagrant, but it is a bug
# if this happens anyways.
raise "UNKNOWN OUTPUT: #{result}"
end
match[1]
# Return the last match, and the capture of it
matches[-1][0]
end
def create(params, **opts, &block)