Merge pull request #11461 from soapy1/get-docker-image-id
Get correct docker image from build output
This commit is contained in:
commit
2dadeb3ee5
@ -24,13 +24,12 @@ module VagrantPlugins
|
||||
args << dir
|
||||
opts = {with_stderr: true}
|
||||
result = execute('docker', 'build', *args, opts, &block)
|
||||
matches = result.match(/Successfully built (?<id>.+)$/i)
|
||||
# Check for the new output format 'writing image sha256...'
|
||||
# In this case, docker builtkit is enabled. Its format is different
|
||||
# from standard docker
|
||||
matches = result.scan(/writing image .+:([0-9a-z]+) done/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(/Successfully built (.+)$/i).last
|
||||
if !matches
|
||||
# This will cause a stack trace in Vagrant, but it is a bug
|
||||
# if this happens anyways.
|
||||
@ -39,7 +38,7 @@ module VagrantPlugins
|
||||
end
|
||||
|
||||
# Return the matched group `id`
|
||||
matches[:id]
|
||||
matches[0]
|
||||
end
|
||||
|
||||
def create(params, **opts, &block)
|
||||
|
||||
@ -153,7 +153,7 @@ describe VagrantPlugins::DockerProvider::Driver do
|
||||
|
||||
|
||||
describe '#build' do
|
||||
let(:result) { "Successfully built 1a2b3c4d" }
|
||||
let(:result) { "Successfully built other_package\nSuccessfully built 1a2b3c4d" }
|
||||
let(:buildkit_result) { "writing image sha256:1a2b3c4d done" }
|
||||
let(:cid) { "1a2b3c4d" }
|
||||
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user