我无法从 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"]
}
Check /etc/default/docker
确保它没有以下行:
DOCKER_OPTS="--iptables=false"
另请检查/etc/docker/daemon.json
确保它没有以下密钥:
{
"iptables":false
}
我们将其添加到一台服务器上,以使 UFW 与 docker 一起工作。然后我们更改为外部防火墙。花了很长时间寻找外部网络无法工作的原因,因为它已从我们的部署指南中删除。希望这对其他人有帮助。
本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系:hwhale#tublm.com(使用前将#替换为@)