这次事件的起因是在使用docker bulid 建立自己的镜像文件时,出现下面的错误提示:
Err:80 http://security.ubuntu.com/ubuntu bionic-updates/universe amd64 libsw
Connection failed [IP: 185.125.190.36 80]
大概意思就是有一些包因为网络问题出现Connection failed 和 failed to fetch,我最后的解决方法参考以下链接:
Docker下载包的时候显示Connection failed [IP: 91.189.88.142 80]_东猪的博客-CSDN博客
具体操作为在Dockerfile FROM ***下面,加上以下代码:
RUN sed -i s:/archive.ubuntu.com:/mirrors.tuna.tsinghua.edu.cn/ubuntu:g /etc/apt/sources.list
RUN cat /etc/apt/sources.list
RUN apt-get clean
RUN apt-get -y update --fix-missing
但是在解决问题之前,还进行了一系列尝试,其中就包括干碎docker操作:
起因是我看到这个博客的解决方法:docker build镜像时容器联网失败的故障 已解决 - 老汉学IT - 博客园
照着敲了一遍,报错是docker没停,然后我直接sudo systemctl stop docker,再输入一次上面的命令没啥反应,然后再打开docker,输入docker ps命令就报错Cannot connect to the Docker daemon at unix:///var/run/docker.sock.
经过多次尝试以后,最后发现是systemctl stop docker以后,它会有一行提示:Warning: Stopping docker.service, but it can still be activated by: docker.socket. 这行命令就是说虽然docker停了,但是docker.socket没停止,这就会导致docker ps的时候出现查找docker.socket有疑义,导致无法连接到Docker daemon, 所以我们需要有一个意识,执行 systemctl stop docker
后要执行systemctl stop docker.socket,把原本docker的东西都停干净了,然后再重新docker即可。
# 先停止docker
sudo systemctl stop docker
# 再停止docker.socket
systemctl stop docker.socket
参考:
Docker下载包的时候显示Connection failed [IP: 91.189.88.142 80]_东猪的博客-CSDN博客
Warning: Stopping docker.service, but it can still be activated by: docker.socket_HoneySJ的博客-CSDN博客