Windows版Docker如何在容器内访问ipv6?

如题,求助,如何在windows版的docker容器内如何访问ipv6网络,按照官方教程配置了ipv6前缀之后可以获得一个内网ipv6地址,但是还是无法访问任何ipv6的网络,网上的方法试了都不太行,有懂的老哥吗?(PS:宿主机是可以正常访问ipv6资源的)
小米8 Explore Edition (透明色)

回复列表(17|隐藏机器人聊天)
  • @Ta / 2023-02-19 / /

    @ChatGPT 2,如何启动一个可以访问公网IPv6的docker容器?

  • @Ta / 2023-02-19 / /

    @ChatGPT 2,如何启动一个可以访问公网IPv6的docker容器?

  • @Ta / 2023-02-19 / /

    @ChatGPT 2,如何启动一个可以访问公网IPv6的docker容器?

  • @Ta / 2023-02-19 / /

    @老虎会游泳,要启动一个可以访问公网 IPv6 的 Docker 容器,需要做以下几个步骤:

    1. 确保主机已开启 IPv6 支持。在 Linux 中,可以使用 ifconfig 命令来查看主机的 IPv6 地址。如果没有 IPv6 地址,需要启用 IPv6 支持。

    2. 确保 Docker 已开启 IPv6 支持。在 Docker 中,IPv6 默认是禁用的。可以通过修改 /etc/docker/daemon.json 文件来启用 IPv6 支持。示例配置如下:

    {
        "ipv6": true,
        "fixed-cidr-v6": "2001:db8:1::/64"
    }
    
    1. 创建一个新的 Docker 网络,指定 IPv6 子网和 IPv6 网关。可以使用以下命令创建一个名为 my-network 的 Docker 网络,IPv6 子网为 2001:db8:1::/64,IPv6 网关为 2001:db8:1::1
    docker network create --ipv6 --subnet=2001:db8:1::/64 --gateway=2001:db8:1::1 my-network
    
    1. 启动一个新的 Docker 容器,指定上面创建的 Docker 网络,并分配 IPv6 地址。可以使用以下命令启动一个名为 my-container 的 Docker 容器,分配 IPv6 地址 2001:db8:1::2
    docker run --network my-network --ip6 2001:db8:1::2 --name my-container -it ubuntu /bin/bash
    

    这样就可以启动一个可以访问公网 IPv6 的 Docker 容器了。需要注意的是,主机和容器的防火墙也需要相应地开放 IPv6 网络访问权限。

  • @Ta / 2023-02-19 / /

    @ChatGPT 2,如何为docker容器开启IPv6 NAT?

  • @Ta / 2023-02-19 / /

    @老虎会游泳,要为 Docker 容器开启 IPv6 NAT,需要在主机上开启 IPv6,并在 Docker 中设置 IPv6 NAT。

    下面是一些具体步骤:

    1. 在主机上开启 IPv6。

    2. 修改 Docker 守护进程的配置文件 /etc/docker/daemon.json。在该文件中添加以下内容:

      {
        "ipv6": true,
        "fixed-cidr-v6": "<CIDR_RANGE>"
      }
      

      CIDR_RANGE 是一个 IPv6 地址段,用于为容器分配 IPv6 地址。例如,你可以使用 2001:db8::/64

    3. 重启 Docker 守护进程,以使配置生效。

    4. 在 Dockerfile 中设置容器的 IPv6 地址。可以使用以下命令:

      FROM debian
      RUN echo 'net.ipv6.conf.all.disable_ipv6=0' >> /etc/sysctl.conf && sysctl -p
      

      这将打开容器的 IPv6 功能,并启用 IPv6 NAT。

  • @Ta / 2023-02-19 / /

    @ChatGPT,WSL2支持IPv6吗?

  • @Ta / 2023-02-19 / /

    @老虎会游泳,是的,WSL2支持IPv6。从Windows 10版本2004开始,WSL2开始支持IPv6。可以使用IPv6地址访问WSL2中运行的应用程序。

  • @Ta / 2023-02-19 / /

    @听风念,如果WSL2支持IPv6,那么WSL2 docker里的容器用--network=host应该就能用上IPv6了啊。

  • @Ta / 2023-02-19 / /

    @老虎会游泳,我连wsl2版的ubuntu都用不了IPv6
    小米8 Explore Edition (透明色)

  • @Ta / 2023-02-19 / /

    我在docker里执行了第二部,可以获取到ipv6地址,但是无法访问ipv6网络,我试试加上第三部能行不
    小米8 Explore Edition (透明色)

  • @Ta / 2023-02-20 / /

    @加勒比海带,WSL 2 (Windows Subsystem for Linux 2) 是一种在 Windows 10 系统上运行 Linux 环境的方法,它通过虚拟机技术提供了一个完整的 Linux 环境。

    如果您在 WSL 2 中读取 Windows 文件速度慢,可以尝试以下解决办法:

    1. 更新 WSL 2 内核:请确保您正在使用最新版本的 WSL 2 内核,并安装任何可用的更新。

    2. 更改文件系统:WSL 2 默认使用 ext4 文件系统,您可以考虑更改为其他文件系统,例如 Btrfs,以提高读取速度。

    3. 调整虚拟内存:如果您的系统有足够的内存,请考虑调整虚拟内存以提高 WSL 2 的性能。

    4. 减少网络延迟:如果您的文件位于远程网络位置,请考虑减少网络延迟以提高读取速度。

    希望以上信息能帮助您解决 WSL 2 读取 Windows 文件速度慢的问题。如果仍然无法解决问题,建议您请教专业人士。

  • @Ta / 2023-02-24 / /

    @ChatGPT,Error response from daemon: Pool overlaps with other one on this address space
    小米8 Explore Edition (透明色)

  • @Ta / 2023-02-24 / /

    [新会话] @听风念,I'm sorry, but the error response you provided seems to be related to Docker. This error typically occurs when there are conflicts between Docker's network address spaces.

    To resolve this issue, you can try the following steps:

    1. Stop all running Docker containers: docker stop $(docker ps -q)

    2. Remove all Docker containers: docker rm $(docker ps -a -q)

    3. Remove all Docker networks: docker network rm $(docker network ls -q)

    4. Restart the Docker daemon: sudo service docker restart

    After following these steps, try running your Docker command again and see if the issue has been resolved. If the problem persists, you may need to further investigate your Docker network configuration.

  • @Ta / 2023-02-24 / /

    @ChatGPT,容器获取到ipv6地址但是仍然无法访问ipv6网络
    小米8 Explore Edition (透明色)

  • @Ta / 2023-02-24 / /

    @听风念,If your container has been assigned an IPv6 address but is still unable to access the IPv6 network, there are a few things you can try:

    1. Check your host network configuration: Ensure that your host machine has an active IPv6 connection and is properly configured to support IPv6 networking.

    2. Check your container network configuration: Make sure that your container's network configuration is set up correctly to support IPv6. For example, you may need to specify an IPv6 subnet for your container's network.

    3. Check your container's firewall settings: Verify that your container's firewall is properly configured to allow traffic over IPv6.

    4. Check your container's routing table: Ensure that your container's routing table is properly set up to route traffic over IPv6.

    5. Try accessing an IPv6 website or resource: Test whether your container is able to access a resource that is only available over IPv6, such as an IPv6-only website. This can help you identify whether the issue is with your container's networking configuration or with the resource you are trying to access.

    If none of these steps resolve the issue, you may need to provide more information about your specific setup and the error messages you are seeing in order to further diagnose the problem.

  • @Ta / 2023-02-24 / /

    @听风念,首次对话使用的语言会变成后续回复语言。所以第一句要有中文。

添加新回复
回复需要登录