Docker Community Forums

Share and learn in the Docker community.

Domain name resolution cannot be performed inside the custom network docker container

自定义docker网络

docker network create first
docker run -it -d --name tomcat --network first tomcat:8.0
docker exec -it tomcat /bin/bash

无法进行域名解析

ping www.baidu.com
ping: unknown host www.baidu.com

下面是配置信息

[root@tencent ~]# cat /etc/redhat-release
CentOS Linux release 7.6.1810 (Core)
[root@tencent ~]# docker version
Client:
 Version:           18.06.3-ce
 API version:       1.38
 Go version:        go1.10.3
 Git commit:        d7080c1
 Built:             Wed Feb 20 02:26:51 2019
 OS/Arch:           linux/amd64
 Experimental:      false

Server:
 Engine:
  Version:          18.06.3-ce
  API version:      1.38 (minimum version 1.12)
  Go version:       go1.10.3
  Git commit:       d7080c1
  Built:            Wed Feb 20 02:28:17 2019
  OS/Arch:          linux/amd64
  Experimental:     false

宿主机nat转发已开启

[root@tencent ~]# cat /proc/sys/net/ipv4/ip_forward
1