关于docker:主机ip6容器ip6以及应用ip6

1次阅读

共计 1294 个字符,预计需要花费 4 分钟才能阅读完成。

启用 ip6

齐全启用 ip6 配置并不简略

  1. 宿主机启用 ip6

sysctl net.ipv6.bindv6only=0
sysctl net.ipv6.conf.default.forwarding=1
sysctl net.ipv6.conf.all.forwarding=1

  1. docker demond 启用 ipv6
    Edit /etc/docker/daemon.json, set the ipv6 key to true and the fixed-cidr-v6 key to your IPv6 subnet. In this example we are setting it to 2001:db8:1::/64.

    
    {
      "ipv6": true,
      "fixed-cidr-v6": "2001:db8:1::/64"
    }
    
    Save the file.
    Reload the Docker configuration file.
    
    $ systemctl reload docker
  2. 容器内的 利用 也必须启用 ip6

mongo 利用默认 不反对 ip6

导致外网 ip6 无法访问

Using a custom MongoDB configuration file
For a more complicated configuration setup, you can still use the MongoDB configuration file. mongod does not read a configuration file by default, so the –config option with the path to the configuration file needs to be specified. Create a custom configuration file and put it in the container by either creating a custom Dockerfile FROM mongo or mounting it from the host machine to the container. See the MongoDB manual for a full list of configuration file options.

For example, /my/custom/mongod.conf is the path to the custom configuration file. Then start the MongoDB container like the following:

$ docker run –name some-mongo -v /my/custom:/etc/mongo -d mongo –config /etc/mongo/mongod.conf

To bind to all IPv4 addresses, you can specify the bind ip address of 0.0.0.0. To bind to all IPv4 and IPv6 addresses, you can specify the bind ip address of ::,0.0.0.0 or alternatively, use the new net.bindIpAll setting or the new command-line option –bind_ip_all.

来聊聊把,共同进步

正文完
 0