docker images -a
REPOSITORY TAG IMAGE ID CREATED SIZE
node test 337b7fc90dbc 2 hours ago 301.8 MB
<none> <none> 60d47994bba8 2 hours ago 301.8 MB
<none> <none> 987deffef7bf 2 hours ago 196.7 MB
docker.io/centos centos7 970633036444 4 weeks ago 196.7 MB
docker ps -a
CONTAINER ID IMAGE COMMAND CREATED STATUS PORTS NAMES
774f0d06ec9a 970633036444 "bash" 2 hours ago Exited (1) 30 minutes ago elated_cray
b1f9481f6eae 337b7fc90dbc "bash" 2 hours ago Exited (0) 30 minutes ago serene_stallman
但是,当我运行时docker rmi 987deffef7bf
,出现错误
Failed to remove image (987deffef7bf): Error response from daemon: conflict: unable to delete 987deffef7bf (cannot be forced) - image has dependent child images
答案1
这表明另一个图像(很可能是时间戳中的“节点”)正在使用该图像作为其图层的一部分。这是从图层创建图像的设计,并将docker images -a
其中一些工作方式公开给最终用户。如果您删除“节点”图像,这些图像应该会自动清除。
答案2
无论如何,只需运行docker rmi -f 987deffef7bf
,即可强制执行。或者,先删除子图像,然后再删除它。