我有一个正在尝试构建的 docker 容器。不幸的是,我无法在其中安装任何东西。apt-get update
根本不起作用。奇怪的是,我可以正常访问curl
文件。我不太明白这里发生了什么。
Ping 似乎运行正常:
root@1605103d18c0:/# ping ports.ubuntu.com -c 3
PING ports.ubuntu.com (91.189.88.150) 56(84) bytes of data.
64 bytes from astomi.canonical.com (91.189.88.150): icmp_seq=1 ttl=51 time=91.2 ms
64 bytes from astomi.canonical.com (91.189.88.150): icmp_seq=2 ttl=51 time=89.3 ms
64 bytes from astomi.canonical.com (91.189.88.150): icmp_seq=3 ttl=51 time=88.4 ms
--- ports.ubuntu.com ping statistics ---
3 packets transmitted, 3 received, 0% packet loss, time 2000ms
rtt min/avg/max/mdev = 88.440/89.672/91.246/1.170 ms
curl
工作正常(我将其输入wc -c
只是为了报告下载的大小)
root@1605103d18c0:/# curl http://ports.ubuntu.com/ubuntu-ports/dists/bionic/InRelease | wc -c
% Total % Received % Xferd Average Speed Time Time Time Current
Dload Upload Total Spent Left Speed
100 236k 100 236k 0 0 403k 0 --:--:-- --:--:-- --:--:-- 403k
242048
apt update
和apt-get
更新均因解决失败而失败。
root@1605103d18c0:/# apt update
Err:1 https://repo.nordvpn.com/deb/nordvpn/debian stable InRelease
Temporary failure resolving 'repo.nordvpn.com'
Err:2 http://ports.ubuntu.com/ubuntu-ports bionic InRelease
Temporary failure resolving 'ports.ubuntu.com'
Err:3 http://ports.ubuntu.com/ubuntu-ports bionic-updates InRelease
Temporary failure resolving 'ports.ubuntu.com'
Err:4 http://ports.ubuntu.com/ubuntu-ports bionic-backports InRelease
Temporary failure resolving 'ports.ubuntu.com'
Err:5 http://ports.ubuntu.com/ubuntu-ports bionic-security InRelease
Temporary failure resolving 'ports.ubuntu.com'
Reading package lists... Done
Building dependency tree
Reading state information... Done
All packages are up to date.
W: Failed to fetch http://ports.ubuntu.com/ubuntu-ports/dists/bionic/InRelease Temporary failure resolving 'ports.ubuntu.com'
W: Failed to fetch http://ports.ubuntu.com/ubuntu-ports/dists/bionic-updates/InRelease Temporary failure resolving 'ports.ubuntu.com'
W: Failed to fetch http://ports.ubuntu.com/ubuntu-ports/dists/bionic-backports/InRelease Temporary failure resolving 'ports.ubuntu.com'
W: Failed to fetch http://ports.ubuntu.com/ubuntu-ports/dists/bionic-security/InRelease Temporary failure resolving 'ports.ubuntu.com'
W: Failed to fetch https://repo.nordvpn.com/deb/nordvpn/debian/dists/stable/InRelease Temporary failure resolving 'repo.nordvpn.com'
W: Some index files failed to download. They have been ignored, or old ones used instead.
答案1
docker-compose.yml
version: "3.7"
services:
app:
build:
network: host
dockerfile: dockerfiles/application.Dockerfile