Skip to content

Commit bc61990

Browse files
committed
Add debug logging to identify container/image ID mismatch
1 parent fe4f432 commit bc61990

File tree

1 file changed

+12
-2
lines changed

1 file changed

+12
-2
lines changed

spec/spec_helper.rb

Lines changed: 12 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -15,11 +15,21 @@ def create_image(version)
1515

1616
def delete_image
1717
puts "Deleting image..."
18+
puts "Image ID to delete: #{@image.id}"
19+
1820
# Stop and remove only containers created from this image
1921
Docker::Container.all(:all => true).each do |container|
20-
image_id = container.info['Image']
22+
container_image = container.info['Image']
23+
container_image_id = container.info['ImageID']
24+
25+
puts "Container #{container.id[0..11]}: Image=#{container_image}, ImageID=#{container_image_id}"
26+
2127
# Match both short and long image IDs
22-
if image_id == @image.id || image_id == @image.id[0..11] || container.info['ImageID'] == @image.id
28+
if container_image == @image.id ||
29+
container_image == @image.id[0..11] ||
30+
container_image_id == @image.id ||
31+
container_image_id == @image.id[0..11]
32+
puts " -> Matches! Removing container #{container.id[0..11]}"
2333
begin
2434
container.stop unless container.info['State'] == 'exited'
2535
container.delete(:force => true)

0 commit comments

Comments
 (0)