From e749eaa039b2682148bc528cdabe76e386f29901 Mon Sep 17 00:00:00 2001 From: Mitchell Hashimoto Date: Tue, 21 Oct 2014 17:44:48 -0700 Subject: [PATCH] providers/docker: more robustly detect built image [GH-4598] --- CHANGELOG.md | 2 ++ plugins/providers/docker/driver.rb | 8 ++++---- 2 files changed, 6 insertions(+), 4 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 02674cb97..9e19f3b65 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -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] diff --git a/plugins/providers/docker/driver.rb b/plugins/providers/docker/driver.rb index 5df5357e0..f5d64fe32 100644 --- a/plugins/providers/docker/driver.rb +++ b/plugins/providers/docker/driver.rb @@ -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)