在我的主机上,ipv6正在运行:
bessarabov@5:~$ curl --silent --verbose ipv6.google.com 2>&1 | head
* Rebuilt URL to: ipv6.google.com/
* Trying 2a00:1450:4010:c04::71...
* Connected to ipv6.google.com (2a00:1450:4010:c04::71) port 80 (#0)
> GET / HTTP/1.1
> Host: ipv6.google.com
> User-Agent: curl/7.43.0
> Accept: */*
>
< HTTP/1.1 200 OK
< Date: Mon, 01 Feb 2016 08:44:04 GMT
但是在docker里面没有ipv6:
$ docker run --rm -it ubuntu:14.04.3 bash
root@54c52afa87ee:/# ifconfig
eth0 Link encap:Ethernet HWaddr 02:42:ac:11:00:02
inet addr:172.17.0.2 Bcast:0.0.0.0 Mask:255.255.0.0
inet6 addr: fe80::42:acff:fe11:2/64 Scope:Link
UP BROADCAST RUNNING MULTICAST MTU:1500 Metric:1
RX packets:8 errors:0 dropped:0 overruns:0 frame:0
TX packets:8 errors:0 dropped:0 overruns:0 carrier:0
collisions:0 txqueuelen:0
RX bytes:648 (648.0 B) TX bytes:648 (648.0 B)
lo Link encap:Local Loopback
inet addr:127.0.0.1 Mask:255.0.0.0
inet6 addr: ::1/128 Scope:Host
UP LOOPBACK RUNNING MTU:65536 Metric:1
RX packets:0 errors:0 dropped:0 overruns:0 frame:0
TX packets:0 errors:0 dropped:0 overruns:0 carrier:0
collisions:0 txqueuelen:0
RX bytes:0 (0.0 B) TX bytes:0 (0.0 B)
root@54c52afa87ee:/# apt-get install -y curl
...
root@54c52afa87ee:/# curl --silent --verbose ipv6.google.com 2>&1 | head
* Rebuilt URL to: ipv6.google.com/
* Hostname was NOT found in DNS cache
* Trying 2a00:1450:4010:c04::71...
* Immediate connect fail for 2a00:1450:4010:c04::71: Network is unreachable
* Closing connection 0
root@54c52afa87ee:/#
如何才能从docker容器访问ipv6主机?
我在我的Mac上使用了docker。我已经用docker-toolbox安装了它。
bessarabov@5:~$ docker version
Client:
Version: 1.9.1
API version: 1.21
Go version: go1.4.3
Git commit: a34a1d5
Built: Fri Nov 20 17:56:04 UTC 2015
OS/Arch: darwin/amd64
Server:
Version: 1.9.1
API version: 1.21
Go version: go1.4.3
Git commit: a34a1d5
Built: Fri Nov 20 17:56:04 UTC 2015
OS/Arch: linux/amd64
bessarabov@5:~$ docker-machine ls
NAME ACTIVE URL STATE URL SWARM DOCKER ERRORS
default * virtualbox Running tcp://192.168.99.100:2376 v1.9.1
bessarabov@5:~$
答案 0 :(得分:0)
来自doc
https://docs.docker.com/engine/userguide/networking/default_network/ipv6/
我看到了
默认情况下,Docker服务器仅为IPv4配置容器网络。您可以通过使用--ipv6标志运行Docker守护程序来启用IPv4 / IPv6双栈支持。
您是否使用IPv6启动docker守护程序?