root@server:~# docker images -a        
REPOSITORY              TAG                 IMAGE ID            CREATED             VIRTUAL SIZE
<none>                  <none>              5e2dfc857e73        5 days ago          261.6 MB
<none>                  <none>              d053e988f23d        5 days ago          261.6 MB
<none>                  <none>              1d5d4a2d89eb        5 days ago          261.6 MB
<none>                  <none>              ea0d189fdb19        5 days ago          100.5 MB
<none>                  <none>              26c6175962b3        5 days ago          100.5 MB
<none>                  <none>              73d5cec4a0b3        5 days ago          100.5 MB
<none>                  <none>              e19590e1bac1        5 days ago          100.5 MB

我试过以下几种方法:

docker rmi $(docker images | grep "^<none>" | awk "{print $3}")

以及以下几点:

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

得到以下错误:

docker: "rmi" requires a minimum of 1 argument.
See 'docker rmi --help'.

Usage:  docker rmi [OPTIONS] IMAGE [IMAGE...]

Remove one or more images

当前回答

第一个解决方案:

首先删除不使用的容器。 docker ps -a | grep -v Up | awk '{打印$1;}' | xargs docker rm 删除所有没有标签的容器。 Docker images | grep none | awk '{打印$3;}' | xargs docker rmi


第二种解决方案删除所有:

$ docker system prune -a


WARNING! This will remove:
- all stopped containers
- all networks not used by at least one container
- all images without at least one container associated to them
- all build cache

Are you sure you want to continue? [y/N]

其他回答

第一个解决方案:

首先删除不使用的容器。 docker ps -a | grep -v Up | awk '{打印$1;}' | xargs docker rm 删除所有没有标签的容器。 Docker images | grep none | awk '{打印$3;}' | xargs docker rmi


第二种解决方案删除所有:

$ docker system prune -a


WARNING! This will remove:
- all stopped containers
- all networks not used by at least one container
- all images without at least one container associated to them
- all build cache

Are you sure you want to continue? [y/N]

移除悬空(<none>)图像的最简单的解决方案应该是:

docker image prune

您还可以添加——force或-f来禁用提示符。

它简单明了,

我花了3天时间才理解这个简单明了的错误。

docker映像未成功构建

Step 7/13 : COPY jupyter_notebook_config.py /root/.jupyter/
 ---> bf29ce6fe6dc
Step 8/13 : COPY notebooks /notebooks
COPY failed: stat /var/lib/docker/tmp/docker-builder776981166/notebooks: no such file or directory
anarchist@anarchist-desktop:~/Documents/sam/dockerDem$ docker images
REPOSITORY          TAG                 IMAGE ID            CREATED             SIZE
<none>              <none>              bf29ce6fe6dc        9 seconds ago       1.27GB
ubuntu              16.04               a51debf7e1eb        3 weeks ago         116MB

然后我从Dockerfile中删除了第8行,这次成功了。

Successfully built b6724370f8ca
Successfully tagged dem:expo
anarchist@anarchist-desktop:~/Documents/sam/dockerDem$ docker run -it -p 8888:8888 dem:expo
[I 06:11:38.984 NotebookApp] Writing notebook server cookie secret to /root/.local/share/jupyter/runtime/notebook_cookie_secret
[I 06:11:39.011 NotebookApp] Serving notebooks from local directory: /
[I 06:11:39.011 NotebookApp] The Jupyter Notebook is running at:
[I 06:11:39.011 NotebookApp] http://(296d81166725 or 127.0.0.1):8888/?token=496feb282ef749c05277ef57a51e8a56fedb1c6b337b9f92

它说成功标记dem:expo,这一行是imp在docker进程。

这是tansadio回答的延伸:

如果你得到以下错误:

Error response from daemon: conflict: unable to delete <> (must be forced) - image is being used by stopped container <>

你可以强迫它——force:

docker images | grep none | awk '{ print $3; }' | xargs docker rmi --force
docker image rm $(docker images | grep none)