Merge pull request #13564 from eszense/rmi-patch

docker/provider: handle variation in error text during image removal
This commit is contained in:
Allison Larson 2025-03-14 16:46:16 -07:00 committed by GitHub
commit bc9f0b8c4c
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
2 changed files with 12 additions and 2 deletions

View file

@ -225,8 +225,9 @@ module VagrantPlugins
execute('docker', 'rmi', id)
return true
rescue => e
return false if e.to_s.include?("is using it")
return false if e.to_s.include?("is being used")
return false if e.to_s.include?("is using it") or
e.to_s.include?("is being used") or
e.to_s.include?("is in use")
raise if !e.to_s.include?("No such image")
end

View file

@ -579,6 +579,15 @@ describe VagrantPlugins::DockerProvider::Driver do
subject.rmi(id)
end
end
context 'image is in use by a container' do
before { allow(subject).to receive(:execute).and_raise("image is in use by a container") }
it 'does not remove the image' do
expect(subject.rmi(id)).to eq(false)
subject.rmi(id)
end
end
end
describe '#inspect_container' do