I have some containers that have a frontend and backend network defined. Currently, if I perform a name resolution on those containers I am receiving both addresses.
We should consider a config.json option that excludes specifically labeled OR named networks from being advertised over DNS.
For arguments sake, we'll consider the containers db, redis, and app as created by the following docker-compose file:
networks:
frontend
backend:
internal: true
services:
db:
image: mariadb
networks:
- backend
redis:
image: redis
networks:
- backend
app:
image: my_custom_app
networks:
- backend
- frontend
depends_on:
- db
- redis
If we dig <rawdns_container> app.tld then I should only receive the frontend IP address.
We can achieve this through some configuration option like:
{
"docker.lab.local." {
"type": "containers",
"exclude": {
"labels": [ "DO_NOT_RESOLVE" ]
"names": [ "backend" ]
}
"socket": "unix:////var/run/docker.sock"
},
"lab.local.": {
"type": "forwarding",
"nameservers": [ "192.168.1.250" ]
}
".": {
"type": "forwarding",
"nameservers": [ "208.67.220.220" ]
}
}
The way you would read this is:
- Resolve *.docker.label.local via the Docker API
- If a container has a network labeled
DO_NOT_RESOLVE, then don't return IPs with that network
- If a container has a network named
backend, then don't return IPs associated with that network
So if I try a dig <rawdns_container> app.tld then I would only receive the frontend IP.
I have some containers that have a
frontendandbackendnetwork defined. Currently, if I perform a name resolution on those containers I am receiving both addresses.We should consider a
config.jsonoption that excludes specifically labeled OR named networks from being advertised over DNS.For arguments sake, we'll consider the containers
db,redis, andappas created by the followingdocker-composefile:If we
dig <rawdns_container> app.tldthen I should only receive thefrontendIP address.We can achieve this through some configuration option like:
The way you would read this is:
DO_NOT_RESOLVE, then don't return IPs with that networkbackend, then don't return IPs associated with that networkSo if I try a
dig <rawdns_container> app.tldthen I would only receive thefrontendIP.