我无法从 docker-compose 容器访问外部网络。
考虑以下 docker-compose 文件:
version: '2'
services:
nginx:
image: nginx
使用简单的docker run -it nginx bash
我设法访问外部 IP 或 Internet IP ( ping www.google.com
)。
另一方面,如果我使用 docker-compose 并附加到容器,我无法访问外部 IP 地址/DNS。
码头工人信息:
Containers: 0
Running: 0
Paused: 0
Stopped: 0
Images: 1
Server Version: 1.12.1
Storage Driver: aufs
Root Dir: /var/lib/docker/aufs
Backing Filesystem: extfs
Dirs: 7
Dirperm1 Supported: true
Logging Driver: json-file
Cgroup Driver: cgroupfs
Plugins:
Volume: local
Network: bridge null host overlay
Swarm: inactive
Runtimes: runc
Default Runtime: runc
Security Options: apparmor seccomp
Kernel Version: 4.4.0-38-generic
Operating System: Ubuntu 16.04.1 LTS
OSType: linux
Architecture: x86_64
CPUs: 2
Total Memory: 3.859 GiB
Name: ***
ID: ****
Docker Root Dir: /var/lib/docker
Debug Mode (client): false
Debug Mode (server): false
Registry: https://index.docker.io/v1/
WARNING: No swap limit support
WARNING: bridge-nf-call-iptables is disabled
WARNING: bridge-nf-call-ip6tables is disabled
Insecure Registries:
127.0.0.0/8
docker-compose 1.8.1,构建 878cff1
daemon.json 文件:
{
"iptables" : false,
"dns" : ["8.8.8.8","8.8.4.4"]
}