Duplicate Docker Image ID in Multiple Repositories
I ran into the case where I had a duplicate 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
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
The Duplicate Docker Image ID Fix
To fix a duplicate Docker image ID 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 runningdocker 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.
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
DeployHub Key Features