如何在构build后删除未标记的图像?

首先,我search了很多,像docker images --filter "dangling=true" -q --no-trunc不适用于我。 而且我也删除了所有容器, docker ps -a现在什么也没有显示。

我所做的是通过docker build -t frederickzh/some-image .build立一个新docker build -t frederickzh/some-image . ,标签被分配给新的图像,留下旧的<none> ,例如:

 $ docker images REPOSITORY TAG IMAGE ID CREATED SIZE frederickzh/some-image latest 064afd1e1f42 31 seconds ago 1.86GB frederickzh/some-image <none> c59371df7b4a About an hour ago 1.86GB 

但是如果我运行docker rmi c59371df7b4a ,会出现一个错误:

 Error response from daemon: conflict: unable to delete c59371df7b4a (cannot be forced) - image has dependent child images 

我现在想要做的是从图像列表中删除未标记的条目,但肯定会保持最新的构build不变。

任何帮助,将不胜感激。 谢谢。

UPDATE

因为新的Dockerfile只有几行新的行,实际上新的图像是旧的。 因此, prune命令不适用于我的情况。