删除映像时,出现以下错误
Error response from daemon: conflict: unable to delete 9f8c08f4755e (must be forced) - image is referenced in multiple repositories
查看映像,确实出现大量ID相同,repository或tag不同的映像
ps images
# docker images
REPOSITORY TAG IMAGE ID CREATED SIZE
xproject/api/product-api-service 1.3.0-RELEASE 9f8c08f4755e 2 hours ago 219 MB
xproject/api/product-api-service latest 9f8c08f4755e 2 hours ago 219 MB
xproject/composite/product-composite-service 1.3.0-RELEASE c47d0e8e3983 2 hours ago 216 MB
xproject/composite/product-composite-service latest c47d0e8e3983 2 hours ago 216 MB
xproject/core/review-service 1.3.0-RELEASE 69f8dad275b8 2 hours ago 215 MB
xproject/core/review-service latest 69f8dad275b8 2 hours ago 215 MB
xproject/core/product-service 1.3.0-RELEASE 1fcbdf73e91f 2 hours ago 215 MB
xproject/core/product-service latest 1fcbdf73e91f 2 hours ago 215 MB
xproject/support/zipkin-server 1.3.0-RELEASE 3e34577e0e98 2 hours ago 223 MB
xproject/support/zipkin-server latest 3e34577e0e98 2 hours ago 223 MB
xproject/support/auth-server 1.3.0-RELEASE 008ffb4ce925 2 hours ago 232 MB
xproject/support/auth-server latest 008ffb4ce925 2 hours ago 232 MB
xproject/support/turbine-server 1.3.0-RELEASE e5c4e8165ec9 2 hours ago 216 MB
xproject/support/turbine-server latest e5c4e8165ec9 2 hours ago 216 MB
xproject/support/hystrix-dashboard 1.3.0-RELEASE 69f77c7c7af0 2 hours ago 217 MB
xproject/support/hystrix-dashboard latest 69f77c7c7af0 2 hours ago 217 MB
xproject/support/zuul-server 1.3.0-RELEASE e03b8a22505c 2 hours ago 219 MB
xproject/support/zuul-server latest e03b8a22505c 2 hours ago 219 MB
xproject/support/eureka-server 1.3.0-RELEASE 770629d65b5e 2 hours ago 219 MB
xproject/support/eureka-server latest 770629d65b5e 2 hours ago 219 MB
xproject/support/config-server 1.3.0-RELEASE 5a68713ce2ed 2 hours ago 204 MB
xproject/support/config-server latest 5a68713ce2ed 2 hours ago 204 MB
docker.io/anapsix/alpine-java 8_jdk 1fd6bac7d0ce 5 months ago 172 MB
参考CSDN文章:https://blog.csdn.net/JackLiu16/article/details/80581709
可以用名称删除,但这样太慢。
参考另外一篇文章https://www.cnblogs.com/q4486233/p/6482711.html中批量删除untagged images,也就是那些id为<None>的image的映像的作法,
docker rmi $(docker images | grep "^<none>" | awk "{print $3}")
将<none>替换为上面images中的模式字符 :
docker rmi $(docker images | grep "^xproject" | awk "{print $3}")
顺序删除全部映像。
将该文备忘如下:
1.停止所有的container,这样才能够删除其中的images:
docker stop $(docker ps -a -q)
如果想要删除所有container的话再加一个指令:
docker rm $(docker ps -a -q)
2.查看当前有些什么images
docker images
3.删除images,通过image的id来指定删除谁
docker rmi <image id>
想要删除untagged images,也就是那些id为<None>的image的话可以用
docker rmi $(docker images | grep "^<none>" | awk "{print $3}")
要删除全部image的话
docker rmi $(docker images -q)