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 rmi删除映像

docker images --filter "dangling=true"      

其他回答

try

docker rmi -f $(docker images -a | awk 'NR> 1 || $2 = "<none>" {print $3}') ,而可能有更干净的命令

更新

docker images -a | grep none | awk '{ print $3; }' | xargs docker rmi

您可以简单地尝试一下

Docker系统修剪将做的把戏,它删除

- all stopped containers
- all networks not used by at least one container
- all dangling images
- all dangling build cache

但是要小心使用它!

它简单明了,

我花了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进程。

第一个解决方案:

首先删除不使用的容器。 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]