我有以下图片:

alex@alexvps:~$ sudo docker images
REPOSITORY          TAG                 IMAGE ID            CREATED             VIRTUAL SIZE
<none>              <none>              70c0e19168cf        5 days ago          1.069 GB
<none>              <none>              c2ce80b62174        8 days ago          399.2 MB
<none>              <none>              60afe4036d97        8 days ago          325.1 MB

当我试图删除其中一个时,我会得到:

alex@alexvps:~$ sudo docker rmi 60afe4036d97
Error: Conflict, 60afe4036d97 wasn't deleted
2014/01/28 00:54:00 Error: failed to remove one or more images

我该如何移除它们?为什么会有这样的冲突?


当前回答

首先必须停止/删除在映像上创建的所有不必要的容器。

看看:如何删除旧Docker容器。

之后使用@marcell溶液。

其他回答

首先必须停止/删除在映像上创建的所有不必要的容器。

看看:如何删除旧Docker容器。

之后使用@marcell溶液。

首先,使用以下命令删除所有容器

sudo docker ps -a -q | xargs -n 1 -I {} sudo docker rm {}

然后,使用以下命令根据映像的ID删除映像

sudo docker rmi <image-id>

从Docker开始。1.13.0(2017年1月)有系统剪枝命令:

$ docker system prune --help

Usage:  docker system prune [OPTIONS]

Remove unused data

Options:
-a, --all     Remove all unused images not just dangling ones
-f, --force   Do not prompt for confirmation
    --help    Print usage

移除所有容器

docker ps -q -a | xargs docker rm

强制删除所有Docker映像

docker rmi -f $(docker images -f dangling=true -q)

除了Sunny的回答:

为了在PowerShell窗口中删除Windows机器(使用Docker for Windows)上的所有图像,请执行以下操作:

docker images -q | %{docker rmi -f $_}

为了在PowerShell窗口中删除Windows机器(使用Docker for Windows)上的所有容器,请执行以下操作:

docker ps -a -q | %{docker rm -f $_}