docker中apt-get失败
docker中无法联网导致apt-get失败ERROR解决方法ERROR使用apt-get update更新失败, 报错:Err:19 http://archive.ubuntu.com/ubuntu bionic/main amd64 libpcre3-dev amd64 2:8.39-9Temporary failure resolving 'archive.ubuntu.com'Err:20
ERROR1
使用apt-get update更新失败, 报错:
Err:19 http://archive.ubuntu.com/ubuntu bionic/main amd64 libpcre3-dev amd64 2:8.39-9
Temporary failure resolving 'archive.ubuntu.com'
Err:20 http://archive.ubuntu.com/ubuntu bionic/main amd64 pkg-config amd64 0.29.1-0ubuntu2
Temporary failure resolving 'archive.ubuntu.com'
Ign:21 http://archive.ubuntu.com/ubuntu bionic-updates/main amd64 libglib2.0-dev amd64 2.56.4-0ubuntu0.18.04.9
Err:21 http://security.ubuntu.com/ubuntu bionic-updates/main amd64 libglib2.0-dev amd64 2.56.4-0ubuntu0.18.04.9
Temporary failure resolving 'archive.ubuntu.com'
E: Failed to fetch http://security.ubuntu.com/ubuntu/pool/main/p/python3.6/python3.6-minimal_3.6.9-1~18.04ubuntu1.6_amd64.deb Temporary failure resolving 'archive.ubuntu.com'
这是由于docker里无互联网连接,尝试了ping google.com失败
解决方法
1. 在本机里修改/etc/default/docker
$ sudo vim /etc/default/docker
取消注释: DOCKER_OPTS =“ - dns 8.8.8.8 --dns 8.8.4.4”
2. 重启docker
$ sudo systemctl restart docker
3. 启动Docker守护进程时设置DNS服务器
$ sudo docker -d -D --dns --dns&
ERROR2
Err:1 http://security.ubuntu.com/ubuntu bionic-security InRelease
Couldn't create temporary file /tmp/apt.conf.AgN46q for passing config to apt-key
W: GPG error: http://mirrors.cloud.aliyuncs.com/ubuntu xenial InRelease: Could not execute 'apt-key' to verify signature (is gnupg installed?)
W: The repository 'http://mirrors.cloud.aliyuncs.com/ubuntu xenial InRelease' is not signed.
解决方法
$ chmod 777 /tmp
ERROR3
Err:4 http://archive.ubuntu.com/ubuntu bionic/universe amd64 libflite1 amd64 2.1-release-1
Connection failed [IP: 91.189.88.152 80]
解决方法
修改sources.list文件
sudo vim /etc/apt/sources.list
加入:
deb http://archive.ubuntu.com/ubuntu focal main universe multiverse restricted
deb http://security.ubuntu.com/ubuntu/ focal-security main multiverse universe restricted
deb http://archive.ubuntu.com/ubuntu focal-updates main multiverse universe restricted
将源文件内容全部注释,并添加以下内容任意源
阿里云源
deb http://mirrors.aliyun.com/ubuntu/ focal main restricted universe multiverse
deb-src http://mirrors.aliyun.com/ubuntu/ focal main restricted universe multiverse
deb http://mirrors.aliyun.com/ubuntu/ focal-security main restricted universe multiverse
deb-src http://mirrors.aliyun.com/ubuntu/ focal-security main restricted universe multiverse
deb http://mirrors.aliyun.com/ubuntu/ focal-updates main restricted universe multiverse
deb-src http://mirrors.aliyun.com/ubuntu/ focal-updates main restricted universe multiverse
deb http://mirrors.aliyun.com/ubuntu/ focal-proposed main restricted universe multiverse
deb-src http://mirrors.aliyun.com/ubuntu/ focal-proposed main restricted universe multiverse
deb http://mirrors.aliyun.com/ubuntu/ focal-backports main restricted universe multiverse
deb-src http://mirrors.aliyun.com/ubuntu/ focal-backports main restricted universe multiverse
清华源
deb http://mirrors.tuna.tsinghua.edu.cn/ubuntu/ focal main restricted
deb http://mirrors.tuna.tsinghua.edu.cn/ubuntu/ focal-updates main restricted
deb http://mirrors.tuna.tsinghua.edu.cn/ubuntu/ focal universe
deb http://mirrors.tuna.tsinghua.edu.cn/ubuntu/ focal-updates universe
deb http://mirrors.tuna.tsinghua.edu.cn/ubuntu/ focal multiverse
deb http://mirrors.tuna.tsinghua.edu.cn/ubuntu/ focal-updates multiverse
deb http://mirrors.tuna.tsinghua.edu.cn/ubuntu/ focal-backports main restricted universe multiverse
deb http://mirrors.tuna.tsinghua.edu.cn/ubuntu/ focal-security main restricted
deb http://mirrors.tuna.tsinghua.edu.cn/ubuntu/ focal-security universe
deb http://mirrors.tuna.tsinghua.edu.cn/ubuntu/ focal-security multiverse
4、保存:ESC+:wq!
5、更新源
$ sudo apt-get update
6、更新软件
$ sudo apt-get dist-upgrade
$ sudo apt-get upgrade
更多推荐
所有评论(0)