From 380c25a7ae5efdc39a8545397264e102c0b2bb98 Mon Sep 17 00:00:00 2001 From: sophia Date: Mon, 23 Mar 2020 10:10:19 -0500 Subject: [PATCH] Get last image id from docker output --- plugins/providers/docker/driver.rb | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/plugins/providers/docker/driver.rb b/plugins/providers/docker/driver.rb index 8932c74a2..ba52c9467 100644 --- a/plugins/providers/docker/driver.rb +++ b/plugins/providers/docker/driver.rb @@ -24,13 +24,13 @@ module VagrantPlugins args << dir opts = {with_stderr: true} result = execute('docker', 'build', *args, opts, &block) - matches = result.match(/Successfully built (?.+)$/i) + matches = result.scan(/Successfully built (?.+)$/i).last if !matches # Check for the new output format 'writing image sha256...' # In this case, docker builtkit is enabled. Its format is different # from standard docker @logger.warn("Could not determine docker container ID. Scanning for buildkit output instead") - matches = result.match(/writing image .+:(?[0-9a-z]+) done/i) + matches = result.scan(/writing image .+:(?[0-9a-z]+) done/i).last if !matches # This will cause a stack trace in Vagrant, but it is a bug # if this happens anyways. @@ -39,7 +39,7 @@ module VagrantPlugins end # Return the matched group `id` - matches[:id] + matches[0] end def create(params, **opts, &block)