Skip to content
TheChatArchiveThe Chat Archive
gpt-3.5-turbo-0301· OpenAIAi2 WildChat-4.8M (AI2)

Is there a way to enforce usage of ipv6 for docker compose?

  1. User

    Is there a way to enforce usage of ipv6 for docker compose?

  2. Assistant

    Yes, you can enforce the usage of IPv6 for Docker Compose by adding the following networking configuration to your docker-compose.yml file:

    networks:
      mynet:
        driver: bridge
        ipam:
          driver: default
          config:
            - subnet: fd00:1234:5678::/64
    

    This will create a new bridge network named "mynet" with an IPv6 subnet of fd00:1234:5678::/64. You can specify the subnet based on your specific requirements. Once this configuration is set, all containers that are connected to the "mynet" network will automatically use IPv6 addresses.

  3. User

    is it possible to do so without providing a subnet range to use?

  4. Assistant

    No, it is not possible to enforce the usage of IPv6 for Docker Compose without providing a subnet range to use. The subnet range is required to assign IPv6 addresses to the containers. You can, however, use a defined range, like the Unique Local Addresses (ULA) prefix fc00::/7, which is reserved for private networks and does not require any registration.

    Here is an example configuration using the fc00::/7 prefix:

    networks:
      mynet:
        driver: bridge
        ipam:
          driver: default
          config:
            - subnet: fc00:1234::/64
    

    This will create a bridge network named "mynet" with an IPv6 subnet of fc00:1234::/64, which can also be used to enforce the usage of IPv6 for Docker Compose.

  5. User

    Why does docker not use dns entries in /etc/resolv.conf anymore once a /etc/docker/daemon.json exists?

  6. Assistant

    When a /etc/docker/daemon.json exists, Docker uses the DNS servers specified in that file instead of the ones listed in /etc/resolv.conf.

    This behavior is based on the design of Docker networking, where every container gets its own DNS resolver that can resolve only the names that are resolvable by the DNS servers specified in the Docker daemon configuration file. By default, Docker uses Google’s public DNS server (8.8.8.8) and Cloudflare DNS server (1.1.1.1) as the default DNS servers.

    If you want Docker to use the DNS entries in /etc/resolv.conf, you can set the dns property in the daemon configuration file to null or to an empty array like this:

    {
      "dns": []
    }
    

    This will tell Docker to use the DNS entries listed in /etc/resolv.conf.

  7. User

    Is there any way to configure IPv6 subnets for docker compose somewhere more central than the yml file of an applicatioN?

  8. Assistant

    Yes, you can configure IPv6 subnets for Docker Compose in a more centralized location than the docker-compose.yml file by using the Docker daemon configuration file.

    To do this, you can add a ipv6-forwarding section to the daemon configuration file at /etc/docker/daemon.json. For example:

    {
        "ipv6-forwarding": true,
        "default-address-pools": [
            {"base": "fd00:10::/64", "size": 24}
        ]
    }
    

    In this example, the default-address-pools section specifies a base subnet fd00:10::/64 and a size of 24. The Docker daemon uses this pool to allocate IPv6 addresses to containers that are running on any network by default.

    Once you have added this section to the daemon configuration file, each container that is connected to a bridge network that does not specify its IPv6 subnet will be assigned an address from this pool. This means that you don't need to specify the IPv6 subnet in the docker-compose.yml file for every application.

    Note that you need to make sure that the subnet range you use for default-address-pools is not already in use on your network.