[英]Unable to delete docker image of a running container using -f option
I tried to create a container using the following我尝试使用以下方法创建容器
docker run -it centos bash
and exited without killing it.并没有杀死它就退出了。
Now I'm trying to delete the centos image using its image ID.现在我正在尝试使用其图像 ID 删除 centos 图像。
docker rmi -f 0f3e07c0138f
Error response from daemon: conflict: unable to delete 0f3e07c0138f (cannot be forced) - image is being used by running container a9eab034a426
On docker documentation page , it says " You cannot remove an image of a running container unless you use the -f option."在 docker 文档页面上,它说“除非使用 -f 选项,否则无法删除正在运行的容器的映像。” but still I'm unable to remove image using -f.
但我仍然无法使用 -f 删除图像。 What can be the explanation for this?
对此有何解释? Should there a correction in documentation?
是否应该在文档中进行更正?
a9eab034a426
container is using centos
image. a9eab034a426
容器正在使用centos
映像。 So, to remove centos
, you need to stop and remove a9eab034a426
container.因此,要删除
centos
,您需要停止并删除a9eab034a426
容器。 Run the following lines.运行以下几行。
docker stop a9eab034a426
docker rm a9eab034a426
docker rmi 0f3e07c0138f
See these results查看这些结果
$ sudo docker rmi centos
Error response from daemon: conflict: unable to remove repository reference
"centos" (must force) - container be8f69d76892 is using its referenced image
0f3e07c0138f
$ sudo docker rmi -f 0f3e07c0138f
Error response from daemon: conflict: unable to delete 0f3e07c0138f (cannot be
forced) - image is being used by running container be8f69d76892
$ sudo docker rmi -f centos
Untagged: centos:latest
Untagged:
centos@sha256:f94c1d992c193b3dc09e297ffd54d8a4f1dc946c37cbeceb26d35ce1647f88d9
docker rmi -f option only works on image name if container is running, even then it just untag the image but the image remains there with "none" repo and tag.如果容器正在运行,docker rmi -f 选项仅适用于图像名称,即使它只是取消标记图像,但图像仍保留在那里,并带有“无”存储库和标记。 see
看
<none> <none> 0f3e07c0138f 3 months ago 220MB
And when you will run你什么时候跑
sudo docker ps
you will see that image id is there instead of the image name您将看到图像 ID 而不是图像名称
CONTAINER ID IMAGE
be8f69d76892 0f3e07c0138f
I have removed other info in this docker ps command's result.我已经删除了这个 docker ps 命令的结果中的其他信息。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.