About the apt-get command error resolution method from within the Docker container

Asked 1 years ago, Updated 1 years ago, 49 views

When I tried to update the repository to install the necessary libraries from the container generated from the ubuntu latest image, I received the following error:

root@59eec8e98b0b:/#apt-get update
Err:1 http://security.ubuntu.com/ubuntubionic-security InRelease        
  Temporary failure resolution 'security.ubuntu.com'
Err:2 http://archive.ubuntu.com/ubuntubionic InRelease                  
  Temporary failure resolution 'archive.ubuntu.com'
Err:3 http://archive.ubuntu.com/ubuntubionic-updates InRelease
  Temporary failure resolution 'archive.ubuntu.com'
Err:4 http://archive.ubuntu.com/ubuntubionic-backports InRelease
  Temporary failure resolution 'archive.ubuntu.com'
Reading package lists... Done        
W: Failed to fetch http://archive.ubuntu.com/ubuntu/dists/bionic/InRelease Temporary failure resolution 'archive.ubuntu.com'
W: Failed to fetch http://archive.ubuntu.com/ubuntu/dists/bionic-updates/InRelease Temporary failure resolution 'archive.ubuntu.com'
W: Failed to fetch http://archive.ubuntu.com/ubuntu/dists/bionic-backports/InRelease Temporary failure resolution 'archive.ubuntu.com'
W: Failed to fetch http://security.ubuntu.com/ubuntu/dists/bionic-security/InRelease Temporary failure resolution 'security.ubuntu.com'
W: Some index files failed to download. They have been ignored, or old ones used installed.

The system specifications are as follows:

OS:Ubuntu 18.04.1 LTS
Docker: 18.06.1-ce
Internet ←→ Corporate LAN ←→ Router (Private Address) ←→ PC

On the docker host (Ubuntu OS), you can connect with the outside world without any problems.

The network adapter settings on the docker host are as follows, and along with net information about access from the Docker container to the outside world, there appears to be no particular problem.

1:lo:<LOOPBACK,UP,LOWER_UP>mtu65536qdisc noise state UNKNOWN group default qlen 1000
    link/loopback 00:00:00:00:00brd 00:00:00:00:00:00:00:00:00:00:00:00:00:00:00:00:00:00:00:00:00:00:00:00:00:00:00:00:00:00:00:00:00:00:00:00:00:00:00:00:00:00:00:00:00:00:00:00:00
    intet127.0.0.1/8 scope host lo
       valid_lft forever preferred_lft forever
    inet6::1/128 scope host 
       valid_lft forever preferred_lft forever
2—enp9s0:<BROADCAST, MULTICAST, UP, LOWER_UP>mtu1500qdisc fq_codel state UP group default qlen 1000
    link/ether e0:db:55:a9:3f:24brdff:ff:ff:ff:ff:ff:ff:ff:ff:ff
    inet 192.168.11.2/24brd 192.168.11.255 scope global dynamic noprefixroute enp9s0
       valid_lft169423sec preferred_lft169423sec
    inet6fe80::e52:b647:3b9e:d5c6/64 scope link noprefixroute 
       valid_lft forever preferred_lft forever
3: docker0:<BROADCAST, MULTICAST, UP, LOWER_UP>mtu1500qdisc noise state UP group default 
    link/ether 02:42:06d:9f:87:aebrdff:ff:ff:ff:ff:ff:ff:ff:ff
    inet 172.17.0.1/16brd 172.17.255.255 scope global docker0
       valid_lft forever preferred_lft forever
    inet6fe80::42:6 dff:fe9f:87ae/64 scope link 
       valid_lft forever preferred_lft forever
31—veth70e27c5@if30:<BROADCAST, MULTICAST, UP, LOWER_UP>mtu1500qdisc noise master docker 0 state UP group default 
    link/ether2a:6b:4e:c4:8f:44brdff:ff:ff:ff:ff:ff link-netnsid0
    inet6fe80::286b:4ef:fec4:8f44/64 scope link 
       valid_lft forever preferred_lft forever

The bridge configuration is as follows:

 docker08000.02426d9f87ae no veth70e27c5

When I try to ping from inside the container, I can't even verify access to the host from the command not found container side.

Incidentally, in CentOS, the ping can reach the address under the router, but it seems that the address outside the router is not accessible.

If anyone knows the cause, please take care of it.

docker network

2022-09-29 21:19

1 Answers

The reason for this error was that the appropriate DNS server could not be accessed when accessing content and resources on the external Internet from a Docker container on a PC connected to a local area network.
 One way to access the DNS server was to address it with the option of the run command (format --dns=IP address of the DNS server) at docker container startup, as described in one site information.Therefore, in this case, a local DNS server was configured on the router to which the PC was connected, so it was resolved by specifying the IP address of the router.


2022-09-29 21:19

If you have any answers or tips


© 2024 OneMinuteCode. All rights reserved.