简体   繁体   English

如何从Docker容器访问ipv6主机?

[英]How to access ipv6 host from docker container?

On my host machine the ipv6 is working: 在我的主机上,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

But inside docker there is no ipv6: 但是在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:/#

What should I do to be able to access ipv6 host from docker container? 我应该怎么做才能从Docker容器访问ipv6主机?

I'm using docker on my mac. 我在Mac上使用docker。 I've installed it with docker-toolbox. 我已经用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:~$

from the doc 从文档

https://docs.docker.com/engine/userguide/networking/default_network/ipv6/ https://docs.docker.com/engine/userguide/networking/default_network/ipv6/

I see 我懂了

By default, the Docker server configures the container network for IPv4 only. 默认情况下,Docker服务器仅将容器网络配置为IPv4。 You can enable IPv4/IPv6 dualstack support by running the Docker daemon with the --ipv6 flag. 您可以通过运行带有--ipv6标志的Docker守护程序来启用IPv4 / IPv6双栈支持。

Do you start the docker daemon with IPv6 ? 您是否使用IPv6启动docker守护进程?

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM