场景
在服务器上使用Docker打包成容器来跑服务时,应为磁盘原因要删除不要或者异常的镜像。
删除
查看所以的镜像 docker images -a
REPOSITORY TAG IMAGE ID CREATED SIZE
<none> <none> 40a77735e6d8 6 months ago 643MB
<none> <none> 1dfac08bf90f 6 months ago 643MB
<none> <none> 51fb2ad8ab7b 6 months ago 643MB
<none> <none> 5b46d0b73619 6 months ago 643MB
<none> <none> 3f763ddfd2e3 6 months ago 643MB
<none> <none> 91198512cb38 6 months ago 643MB
<none> <none> bfe44cd4545e 6 months ago 643MB
<none> <none> 73f98df6169a 6 months ago 643MB
<none> <none> ca684730863b 6 months ago 643MB
<none> <none> 2331606985b1 6 months ago 643MB
<none> <none> 37d15734ac63 6 months ago 643MB
<none> <none> 3b67601f31e4 6 months ago 643MB
<none> <none> 02aaa36e210f 6 months ago 643MB
<none> <none> 77ba70c0bc09 6 months ago 643MB
<none> <none> 0af1b42d4e1e 6 months ago 643MB
<none> <none> c1a415ae226a 6 months ago 643MB
<none> <none> a6809ae60385 6 months ago 643MB
<none> <none> 86ae730a4e09 6 months ago 643MB
<none> <none> 94849045b0f9 6 months ago 643MB
<none> <none> d7d939e00406 6 months ago 643MB
<none> <none> f74e4999174f 6 months ago 643MB
<none> <none> 32c9919b50af 6 months ago 643MB
首先直接使用docker rmi 镜像号 删除,但是会报删除镜像异常,异常信息如下:
Deleted: sha256:73f98df6169a91150fcf1448143bf9d762b9a96e1e7094634ac7c03fdef7bbe9
Deleted: sha256:f74e4999174fa9bb5281497ff45564218c1e1cb6bdc56b4465b3a19ba0788e70
Error response from daemon: conflict: unable to delete ca684730863b (cannot be forced) - image has dependent child images
Error response from daemon: conflict: unable to delete 77ba70c0bc09 (cannot be forced) - image has dependent child images
Error response from daemon: conflict: unable to delete 3b67601f31e4 (cannot be forced) - image has dependent child images
Error response from daemon: conflict: unable to delete 02aaa36e210f (cannot be forced) - image has dependent child images
Error response from daemon: conflict: unable to delete 94849045b0f9 (cannot be forced) - image has dependent child images
Error response from daemon: conflict: unable to delete d7d939e00406 (cannot be forced) - image has dependent child images
Error response from daemon: conflict: unable to delete 86ae730a4e09 (cannot be forced) - image has dependent child images
Error response from daemon: conflict: unable to delete d23bdf5b1b1b (cannot be forced) - image has dependent child images
Error response from daemon: conflict: unable to delete d23bdf5b1b1b (cannot be forced) - image has dependent child images
最后通过在后面加入强制删除 --force后成功删除,命令如下:
docker rmi 镜像号 --force