hashicorp / hashicorp/consul

Store both IPv4 and IPv6 addresses for Docker services

Open
#15,902 1 comment 2 reactions 0 assignees View on GitHub
Dominant language
Go
Stars
30.1k
Forks
4.6k
Avg merge
2d 6h
Merged PRs (30d)
43

Description

Our team runs several docker containers as nomad tasks (registered as services with Consul), and we need access to the containers' IPv4 and IPv6 addresses in a [consul template](https://github.com/hashicorp/consul-template). We use Docker bridge networking for our containers, and have the following `daemon.json` settings to enable IPv6 networking for containers:
```
{
"ipv6" : true,
"fixed-cidr-v6": "fd00::/80"
}
```

We've noticed that the addresses registered for these services in Consul are either only IPv4, or only IPv6 (if we set [advertise_ipv6_address](https://developer.hashicorp.com/nomad/docs/drivers/docker#advertise_ipv6_address) in the task configuration):
- when I curl Consul's `/v1/agent/services` endpoint, I see that if `advertise_ipv6_address` is enabled for the service then the `Address` field is the container's IPv6 address and the only automatically-populated tagged addresses are `lan_ipv6` and `wan_ipv6`
- otherwise the `Address` is the container's IPv4 address and we only get `lan_ipv4` and `wan_ipv4`

Because Consul only ever stores either the IPv4 or IPv6 address, it seems like there is no way to get access to both addresses by pulling fields out of the service object in our templates. Would the Consul team be open to auto-populating both the `_ipv4` and `_ipv6` tagged addresses for docker container services, if the container has both types of addresses?

Contributor guide

Open the contributing guide

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.