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版本

上一篇:命令


下一篇:java入门16 -- http编程