Job for docker.service failed because the control……错误在文章末尾处。
首先这是我出现的问题
root@40b82f229080:~# apt-get update Err:1 http://deb.debian.org/debian buster InRelease Temporary failure resolving 'deb.debian.org' Err:2 http://security.debian.org/debian-security buster/updates InRelease Temporary failure resolving 'security.debian.org' Err:3 http://deb.debian.org/debian buster-updates InRelease Temporary failure resolving 'deb.debian.org' Reading package lists... Done W: Failed to fetch http://deb.debian.org/debian/dists/buster/InRelease Temporary failure resolving 'deb.debian.org' W: Failed to fetch http://security.debian.org/debian-security/dists/buster/updates/InRelease Temporary failure resolving 'security.debian.org' W: Failed to fetch http://deb.debian.org/debian/dists/buster-updates/InRelease Temporary failure resolving 'deb.debian.org' W: Some index files failed to download. They have been ignored, or old ones used instead.
出现这个问题,大概率是DNS解析的问题,需要指定下dns
vim /etc/docker/daemon.json { "dns": ["114.114.114.114","8.8.8.8"] }
我是单独添加的,所以这个文件的格式是这个样子的,不知对不对,反正能用就对了
[root@localhost ~]# cat /etc/docker/daemon.json { "registry-mirrors":["https://sri78v3x.mirror.aliyuncs.com"] } { "dns": ["114.114.114.114","8.8.8.8"] }
可以选择重启下docker服务 systemctl restart docker
现在我们再进去看一下
[root@localhost ~]# docker exec -it nginx1 /bin/bash root@40b82f229080:/# apt-get install vim Reading package lists... Done Building dependency tree Reading state information... Done The following additional packages will be installed: libgpm2 vim-common vim-runtime xxd Suggested packages: gpm ctags vim-doc vim-scripts The following NEW packages will be installed: libgpm2 vim vim-common vim-runtime xxd 0 upgraded, 5 newly installed, 0 to remove and 0 not upgraded. Need to get 7425 kB of archives. After this operation, 33.8 MB of additional disk space will be used. Do you want to continue? [Y/n] y Get:1 http://deb.debian.org/debian buster/main amd64 xxd amd64 2:8.1.0875-5 [140 kB] Get:2 http://deb.debian.org/debian buster/main amd64 vim-common all 2:8.1.0875-5 [195 kB] Get:3 http://deb.debian.org/debian buster/main amd64 libgpm2 amd64 1.20.7-5 [35.1 kB] Get:4 http://deb.debian.org/debian buster/main amd64 vim-runtime all 2:8.1.0875-5 [5775 kB] 22% [4 vim-runtime 516 kB/5775 kB 9%]
OK,已经结局了
----------------------------------华丽的分割线---------------------------
2020.0923更
还有种情况,就是需要更换下apt源,否则执行update很慢
mv /etc/apt/sources.list /etc/apt/sources.list.bak cat <<EOF >/etc/apt/sources.list deb http://mirrors.ustc.edu.cn/debian stable main contrib non-free deb http://mirrors.ustc.edu.cn/debian stable-updates main contrib non-free EOF
这个是目前我找到的可以正确更新的两个地址,来自于中国科技大学开源镜像站,摘出来两个能用的网址,大家可以 试试。
下面这个是清华大学开源镜像站找到的 不过我的没法用,可能是我复制粘贴的姿势不对……
所以我还是用的上面的 ,亲测是可用的。
# 默认注释了源码镜像以提高 apt update 速度,如有需要可自行取消注释 deb https://mirrors.tuna.tsinghua.edu.cn/ubuntu/ focal main restricted universe multiverse # deb-src https://mirrors.tuna.tsinghua.edu.cn/ubuntu/ focal main restricted universe multiverse deb https://mirrors.tuna.tsinghua.edu.cn/ubuntu/ focal-updates main restricted universe multiverse # deb-src https://mirrors.tuna.tsinghua.edu.cn/ubuntu/ focal-updates main restricted universe multiverse deb https://mirrors.tuna.tsinghua.edu.cn/ubuntu/ focal-backports main restricted universe multiverse # deb-src https://mirrors.tuna.tsinghua.edu.cn/ubuntu/ focal-backports main restricted universe multiverse deb https://mirrors.tuna.tsinghua.edu.cn/ubuntu/ focal-security main restricted universe multiverse # deb-src https://mirrors.tuna.tsinghua.edu.cn/ubuntu/ focal-security main restricted universe multiverse
+++++++++++++++++++简洁的分割线+++++++++++++++++++++++
还有一种方法 是这样,不过我还没来得及测试:
以163 源为例,在容器内创建 etc/apνsources.list.d/163.list 文件:
cat <<EOF >/etc/apt/sources.list
deb http: //mirrors.163.com/ubuntu / bionic main restricted universe multiverse deb http: //mirrors 163.cαn/ubuntu/ bionic-security main restricted universe multiverse deb http://mirrors.163.com/ubuntu/ bionic-updates main restricted universe multiverse deb http://mirrors.163.cαn/ubuntu/ bionic proposed main restricted universe multiverse deb-src http://mirrors.163.cαn/ubuntu/ bionic main restricted verse mult verse deb-src http //mirrors.163.com/ubuntu/ bionic-security mai restricted universe mul tiverse deb-src http://mirrors.163.com/ubuntu/ bionic updates main restricted universe multiverse deb-src http://mirrors.163.com/ubuntu/ bionic-proposed main restricted universe multiverse
EOF
+++++++++++++++++++简洁的分割线+++++++++++++++++++++++
Job for docker.service failed because the control process exited with error code. See "systemctl status docker.service" and "journalctl -xe" for details.
这个错误,网上有说什么内核问题啊,虚拟化问题啊,至少在我这里不是,我翻看了下日志,原来是因为/etc/docker/daemon.json
文件格式错误了。导致docker服务起不来了,所以回去看看这个文件,十有八九是格式错误了。