使用Docker常见的错误和解决方法
更新:HHH   时间:2023-1-7


今天小编就为大家带来一篇有关使用Docker常见的错误和解决方法的文章。小编觉得挺实用的,为此分享给大家做个参考。一起跟随小编过来看看吧。

操作系统:CentOS Linux release 7.5.1804

容器引擎: Docker version 19.03.7

实战任务:描述问题及解决问题。

1.解决docker镜像无法删除的问题,原因是由于REPOSITORY公用一个IMAGE ID导致删除失败

[root@docker sky9890]# docker rmi $(docker images -q)

Error response from daemon: conflict: unable to delete 5766334bdaa0 (must be forced) - image is 

referenced in multiple repositories

Error response from daemon: conflict: unable to delete 5766334bdaa0 (must be forced) - image is 

referenced in multiple repositories

Error response from daemon: conflict: unable to delete 5766334bdaa0 (must be forced) - image is 

referenced in multiple repositories

#一一删除即可解决问题

[root@docker sky9890]# docker rmi nginx:v1

[root@docker sky9890]# docker rmi nginx:1.11

[root@docker sky9890]# docker rmi nginx

2.遇到怎么都无法删除image的解决办法Error: No such images  

[root@docker sky9890]# docker image rm $(docker image ls -a -q)

Error: No such image: 4e7840b49fad

Error: No such image: a1523e859360

Error: No such image: 0320ef7199ca

[root@docker sky9890]# docker rmi centos:latest

Error: No such image: centos:latest

[root@docker sky9890]# docker rmi 470671670cac

Error: No such image: 470671670cac

#删除sha256下面的缓存文件即可

[root@docker docker]# cd  /var/lib/docker/image/overlay2/imagedb/content/sha256/

[root@docker sha256]# ll

总用量 96

-rw-------. 1 root root  8983 3月   2 12:35 

0320ef7199cad90e23f7d5688a47beab304280b000284e0bd7fdad162ff5c9ec

-rw-------. 1 root root  2797 3月   2 12:28 

470671670cac686c7cf0081e0b37da2e9f4f768ddc5f6a26102ccd1c6954c1ee

-rw-------. 1 root root 14511 3月   2 12:11 

..................................................................

[root@docker sha256]# rm  *

[root@docker sha256]# ll

总用量 0

3.mount参数会报Docker Unknown flag --mount

原因如下:

docker run support for the --mount option was only introduced in Docker 17.06. You are using Docker 1.13.1. You have two choices:

1. Update to Docker 17.06 or later if you can;

2. Use the -v approach to bind mount the volume you require e.g. docker run -v $(pwd):/home

解决方法:升级docker版本

以上就是Docker常见的错误和解决方法的详细内容了,看完之后是否有所收获呢?如果想了解更多相关内容,欢迎关注天达云行业资讯!

返回云计算教程...