Get last image id from docker output

This commit is contained in:
sophia 2020-03-23 10:10:19 -05:00
parent ea7cc687f2
commit 380c25a7ae

View File

@ -24,13 +24,13 @@ module VagrantPlugins
args << dir
opts = {with_stderr: true}
result = execute('docker', 'build', *args, opts, &block)
matches = result.match(/Successfully built (?<id>.+)$/i)
matches = result.scan(/Successfully built (?<id>.+)$/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 .+:(?<id>[0-9a-z]+) done/i)
matches = result.scan(/writing image .+:(?<id>[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)