docker 容器内无法解析域名 System error resolving

发布时间 2023-05-15 09:38:13作者: 李悠然

root@mission:/etc/apt# apt-get update
Err:1 http://mirrors.ustc.edu.cn/ubuntu focal InRelease
  System error resolving 'mirrors.ustc.edu.cn:http' - getaddrinfo (16: Device or resource busy)
Err:2 http://mirrors.ustc.edu.cn/ubuntu focal-updates InRelease
  System error resolving 'mirrors.ustc.edu.cn:http' - getaddrinfo (16: Device or resource busy)
Err:3 http://mirrors.ustc.edu.cn/ubuntu focal-backports InRelease
  System error resolving 'mirrors.ustc.edu.cn:http' - getaddrinfo (16: Device or resource busy)
Err:4 http://mirrors.ustc.edu.cn/ubuntu focal-security InRelease
  System error resolving 'mirrors.ustc.edu.cn:http' - getaddrinfo (16: Device or resource busy)
Err:5 http://archive.canonical.com/ubuntu focal InRelease
  System error resolving 'archive.canonical.com:http' - getaddrinfo (16: Device or resource busy)
Reading package lists... Done
W: Failed to fetch http://mirrors.ustc.edu.cn/ubuntu/dists/focal/InRelease  System error resolving 'mirrors.ustc.edu.cn:http' - getaddrinfo (16: Device or resource busy)
W: Failed to fetch http://mirrors.ustc.edu.cn/ubuntu/dists/focal-updates/InRelease  System error resolving 'mirrors.ustc.edu.cn:http' - getaddrinfo (16: Device or resource busy)
W: Failed to fetch http://mirrors.ustc.edu.cn/ubuntu/dists/focal-backports/InRelease  System error resolving 'mirrors.ustc.edu.cn:http' - getaddrinfo (16: Device or resource busy)
W: Failed to fetch http://mirrors.ustc.edu.cn/ubuntu/dists/focal-security/InRelease  System error resolving 'mirrors.ustc.edu.cn:http' - getaddrinfo (16: Device or resource busy)
W: Failed to fetch http://archive.canonical.com/ubuntu/dists/focal/InRelease  System error resolving 'archive.canonical.com:http' - getaddrinfo (16: Device or resource busy)
W: Some index files failed to download. They have been ignored, or old ones used instead.

可以定位为网络问题

1. 查看是否禁用ip

root@mission:~# cat /proc/sys/net/ipv4/ip_forward
1

0表示禁用,需要开启

nano /etc/sysctl.conf

打开内核配置文件,查找net.ipv4.ip_forward = 0,将其修改为net.ipv4.ip_forward = 1

2. 重启

root@mission:~# sysctl -p /etc/sysctl.conf
root@mission:~# apt-get update