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

启用 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.

来聊聊把,共同进步

【腾讯云】轻量 2核2G4M,首年65元

阿里云限时活动-云数据库 RDS MySQL  1核2G配置 1.88/月 速抢

本文由乐趣区整理发布,转载请注明出处,谢谢。

您可能还喜欢...

发表回复

您的电子邮箱地址不会被公开。 必填项已用*标注

此站点使用Akismet来减少垃圾评论。了解我们如何处理您的评论数据