A solution to the problem that Docker Image images cannot be deleted
- 2020-08-22 23:19:09
- OfStack
preface
Docker is an open source container engine project of Docker.Inc based on lightweight virtualization technology. The entire project is developed based on Go language and complies with Apache 2.0 protocol. By standardizing layered mirroring and kernel virtualization, Docker enables application developers and operations engineers to distribute applications across platforms in a unified manner and provide a resource-isolated application runtime environment with little additional overhead. Due to its many novel features and the openness of the project itself, Docker quickly gained the participation of many IT manufacturers in less than two years, among which Google, Microsoft, VMware and other industry leaders. At the same time, Docker has aroused waves in the developer community. Many code farmers like me have begun to pay attention to, learn from and use Docker. Many enterprises, especially Internet enterprises, are also increasing their investment in Docker, which is likely to set off a container revolution.
Identify problems:
Mirroring is one of the core Docker technologies and is the standard format for application publishing. Recently, I have encountered a problem in my work, which is as follows:
Error response from daemon: conflict: unable to delete 4ac2d12f10cd (must be forced) - image is referenced in multiple repositories
Error response from the daemon: conflict: unable to delete 4 ac2d12f10cd (mandatory) - image is referenced in multiple repositories
1. Delete the image
Look at mirror
root@souyunku:~/mydocker# docker images
REPOSITORY TAG IMAGE ID CREATED SIZE
nginx v1 4ac2d12f10cd 41 minutes ago 108MB
souyunku/nginx v1 4ac2d12f10cd 41 minutes ago 108MB
hello-world latest f2a91732366c 5 weeks ago 1.85kB
Delete failed
Remove 1 of the images, which have 1 repo reference and are not used by the container
And there is no container to use
root@souyunku:~/mydocker# docker container ls -a
CONTAINER ID IMAGE COMMAND CREATED STATUS PORTS NAMES
4c104074b3f4 hello-world "/hello" About an hour ago Exited (0) About an hour ago priceless_hawking
The mirror image has 1 repo reference
root@souyunku:~/mydocker# docker rmi 4ac
Error response from daemon: conflict: unable to delete 4ac2d12f10cd (must be forced) - image is referenced in multiple repositories
2. Solutions
Delete REPOSITORY
For the deleted ImageID, there is a reference to the REPOSITORY name. The solution is as follows:
When deleted, specify the name, not IMAGE ID.
root@souyunku:~/mydocker# docker rmi souyunku/nginx:v1
Untagged: souyunku/nginx:v1
Then delete IMAGE ID:
root@souyunku:~/mydocker# docker rmi 4ac
Untagged: nginx:v1
Deleted: sha256:4ac2d12f10cdb99c099749432b7a450ee1c6958e0f2f964cd64c6b086ba3e622
Deleted: sha256:346164f732e08d72d1f64828acda4e5ca93f79473f443ce57d9cfe69d9b66b24
Deleted: sha256:3f8a4339aadda5897b744682f5f774dc69991a81af8d715d37a616bb4c99edf5
Deleted: sha256:bb528503f6f01b70cd8de94372e1e3196fad3b28da2f69b105e95934263b0487
Deleted: sha256:410204d28a96d436e31842a740ad0c827f845d22e06f3b1ff19c3b22706c3ed4
Deleted: sha256:2ec5c0a4cb57c0af7c16ceda0b0a87a54f01f027ed33836a5669ca266cafe97a
3. View the image
root@souyunku:~/mydocker# docker images
REPOSITORY TAG IMAGE ID CREATED SIZE
hello-world latest f2a91732366c 5 weeks ago 1.85kB
conclusion