簡體   English   中英

如何從Docker容器訪問ipv6主機?

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

在我的主機上,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:~$

從文檔

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

我懂了

默認情況下,Docker服務器僅將容器網絡配置為IPv4。 您可以通過運行帶有--ipv6標志的Docker守護程序來啟用IPv4 / IPv6雙棧支持。

您是否使用IPv6啟動docker守護進程?

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM