Duplicate Docker Image ID in Multiple Repositories
I ran into the case where I had the same docker image id that belonged to multiple repositories. This came about from doing a
docker tag
and then a
docker push to get the image on my remote repo.
Output from: docker images
1 2 3 4 5 6 7 8 9 10 11 12 13 14 |
REPOSITORY TAG IMAGE ID CREATED SIZE <strong>deployhub/ui latest b5aba79a8ec6 2 days ago 765.8 MB us.gcr.io/deployhub-v81/dh-ms-ui latest b5aba79a8ec6 2 days ago 765.8 MB</strong> deployhub/general latest 0753d11d873d 2 days ago 765.8 MB deployhub/init latest 85ed3dec88d6 2 days ago 765.8 MB deployhub/nginx-west latest a68e5b29ba5a 2 days ago 107.5 MB deployhub/nginx-east latest d5eaddef76be 2 days ago 107.5 MB deployhub/nginx latest 2043cd31e820 2 days ago 107.5 MB sbtaylor15/dh-ms-general <none> c80df34b8c9a 9 days ago 765.8 MB sbtaylor15/dh-ms-init <none> 162a3ed52aea 9 days ago 765.8 MB <none> <none> 714f80322138 11 days ago 107.5 MB docker.io/openjdk 8 4551430cfe80 4 weeks ago 738.1 MB docker.io/nginx latest b8efb18f159b 4 weeks ago 107.5 MB |
Trying to run docker rmi b5aba79a8ec6 throws:
Error response from daemon: conflict: unable to delete b5aba79a8ec6 (must be forced) – image is referenced in one or more repositories
To fix this you need to first delete one of them. Using docker rmi is the way to go. I originally was looking for an option under docker tag since that is the way you add the image to a repository.
So running docker rmi us.gcr.io/deployhub-v81/dh-ms-ui:latest deletes that image/tag combo.
For images that have no tag sbtaylor15/dh-ms-init <none> 162a3ed52aea you will need to run
docker images --digests to get the full digest value.
1 2 3 4 5 6 7 8 9 10 11 12 |
REPOSITORY TAG DIGEST IMAGE ID CREATED SIZE deployhub/ui latest <none> b5aba79a8ec6 2 days ago 765.8 MB deployhub/general latest <none> 0753d11d873d 2 days ago 765.8 MB deployhub/init latest <none> 85ed3dec88d6 2 days ago 765.8 MB deployhub/nginx-west latest <none> a68e5b29ba5a 2 days ago 107.5 MB deployhub/nginx-east latest <none> d5eaddef76be 2 days ago 107.5 MB deployhub/nginx latest <none> 2043cd31e820 2 days ago 107.5 MB sbtaylor15/dh-ms-general <none> sha256:5d7319d3bd95ce7645ec2894e9efa33bd13a26b7a1f5e380be00c0fc9fa8d840 c80df34b8c9a 9 days ago 765.8 MB sbtaylor15/dh-ms-init <none> sha256:a240cda2ff2ce26ea4dfd2bf5617539d15ae1d7bacbdc7094ab9006853e62da5 162a3ed52aea 9 days ago 765.8 MB <none> <none> <none> 714f80322138 11 days ago 107.5 MB docker.io/openjdk 8 sha256:5da842d59f76009fa27ffde06888ebd560c7ad17607d7cd1e52fc0757c9a45fb 4551430cfe80 4 weeks ago 738.1 MB docker.io/nginx latest sha256:788fa27763db6d69ad3444e8ba72f947df9e7e163bad7c1f5614f8fd27a311c3 b8efb18f159b 4 weeks ago 107.5 MB |
then run docker rmi <repo>@<digest> to delete it.
docker rmi sbtaylor15/dh-ms-init@sha256:a240cda2ff2ce26ea4dfd2bf5617539d15ae1d7bacbdc7094ab9006853e62da5
Some more examples from docker documentation.