docker執行Ubuntu:latest容器,無法連線網路,apt-get報錯
阿新 • • 發佈:2020-10-22
一、狀態
自己製作的arm架構的Ubuntu18系統,docker版本是18.06.03,拉取最新的Ubuntu映象,在映象內使用apt-get update命令出現如下錯誤:
root@73387d64899b:/# apt-get update Err:1 http://deb.debian.org/debian buster InRelease Could not resolve 'deb.debian.org' Err:2 http://security.debian.org/debian-security buster/updates InRelease Could not resolve 'security.debian.org' Err:3 http://deb.debian.org/debian buster-updates InRelease Could not resolve 'deb.debian.org' Reading package lists... Done W: Failed to fetch http://deb.debian.org/debian/dists/buster/InRelease Could not resolve 'deb.debian.org' W: Failed to fetch http://security.debian.org/debian-security/dists/buster/updates/InRelease Could not resolve 'security.debian.org'W: Failed to fetch http://deb.debian.org/debian/dists/buster-updates/InRelease Could not resolve 'deb.debian.org' W: Some index files failed to download. They have been ignored, or old ones used instead.
二、解決
1. 更改hosts檔案,將靜態ip新增進檔案
root@73387d64899b:/# cat /etc/hosts 127.0.0.1 localhost ::1 localhost ip6-localhost ip6-loopback fe00::0 ip6-localnet ff00::0 ip6-mcastprefix ff02::1 ip6-allnodes ff02::2 ip6-allrouters 172.17.0.2 73387d64899b 151.101.128.204 deb.debian.org 151.101.78.133 security.debian.org
出現如下結果,還是有錯誤。
root@73387d64899b:/# apt-get update Ign:1 http://deb.debian.org/debian buster InRelease Ign:2 http://security.debian.org/debian-security buster/updates InRelease Ign:3 http://deb.debian.org/debian buster-updates InRelease Err:4 http://security.debian.org/debian-security buster/updates Release Could not create a socket for 151.101.78.133 (f=2 t=1 p=6) - socket (13: Permission denied) Err:5 http://deb.debian.org/debian buster Release Could not create a socket for 151.101.128.204 (f=2 t=1 p=6) - socket (13: Permission denied) Err:6 http://deb.debian.org/debian buster-updates Release Could not create a socket for 151.101.128.204 (f=2 t=1 p=6) - socket (13: Permission denied) Reading package lists... Done E: The repository 'http://security.debian.org/debian-security buster/updates Release' no longer has a Release file. N: Updating from such a repository can't be done securely, and is therefore disabled by default. N: See apt-secure(8) manpage for repository creation and user configuration details. E: The repository 'http://deb.debian.org/debian buster Release' no longer has a Release file. N: Updating from such a repository can't be done securely, and is therefore disabled by default. N: See apt-secure(8) manpage for repository creation and user configuration details. E: The repository 'http://deb.debian.org/debian buster-updates Release' no longer has a Release file. N: Updating from such a repository can't be done securely, and is therefore disabled by default. N: See apt-secure(8) manpage for repository creation and user configuration details.
2. 更改/etc/passwd檔案,將如下語句的gid:65534改為3003,解決問題
_apt:x:100:65534::/nonexistent:/usr/sbin/nologin
#改為:
_apt:x:100:3003::/nonexistent:/usr/sbin/nologin