Is there a way to enforce usage of ipv6 for docker compose?
- User
Is there a way to enforce usage of ipv6 for docker compose?
- 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::/64This 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.
- User
is it possible to do so without providing a subnet range to use?
- 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::/7prefix:networks: mynet: driver: bridge ipam: driver: default config: - subnet: fc00:1234::/64This 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. - User
Why does docker not use dns entries in /etc/resolv.conf anymore once a /etc/docker/daemon.json exists?
- Assistant
When a
/etc/docker/daemon.jsonexists, 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 thednsproperty in the daemon configuration file tonullor to an empty array like this:{ "dns": [] }This will tell Docker to use the DNS entries listed in
/etc/resolv.conf. - User
Is there any way to configure IPv6 subnets for docker compose somewhere more central than the yml file of an applicatioN?
- Assistant
Yes, you can configure IPv6 subnets for Docker Compose in a more centralized location than the
docker-compose.ymlfile by using the Docker daemon configuration file.To do this, you can add a
ipv6-forwardingsection 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-poolssection specifies a base subnetfd00:10::/64and 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.ymlfile for every application.Note that you need to make sure that the subnet range you use for
default-address-poolsis not already in use on your network.