diff --git a/manifests/image.pp b/manifests/image.pp index 35b2b97fd..c70c5e0fc 100644 --- a/manifests/image.pp +++ b/manifests/image.pp @@ -90,7 +90,7 @@ $image_find = "${docker_command} images --digests | egrep '^(docker.io/)?${image} ' | awk '{ print \$3 }' | grep ^${image_digest}$" } else { $image_arg = $image - $image_remove = "${docker_command} rmi ${image_force}${image}" + $image_remove = "${docker_command} rmi ${image_force}(${docker_command} images | egrep '^(docker.io/)?${image} ' | awk '{ print \$3 }')" $image_find = "${docker_command} images | cut -d ' ' -f 1 | egrep '^(docker\\.io/)?${image}$'" } diff --git a/spec/defines/image_spec.rb b/spec/defines/image_spec.rb index e5d190e77..240da6f34 100644 --- a/spec/defines/image_spec.rb +++ b/spec/defines/image_spec.rb @@ -13,12 +13,12 @@ context 'with ensure => absent' do let(:params) { { 'ensure' => 'absent' } } - it { should contain_exec('docker rmi base') } + it { should contain_exec('docker rmi $(docker images | egrep '^(docker.io/)?base ' | awk '{ print $3 }')') } end context 'with ensure => absent and force => true' do let(:params) { { 'ensure' => 'absent', 'force' => true } } - it { should contain_exec('docker rmi -f base') } + it { should contain_exec('docker rmi -f $(docker images | egrep '^(docker.io/)?base ' | awk '{ print $3 }')') } end context 'with ensure => absent and image_tag => precise' do