Skip to content

Allow filtering the IP addresses that RawDNS returns for a given container #25

@michaeljbailey

Description

@michaeljbailey

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:

  1. Resolve *.docker.label.local via the Docker API
  2. If a container has a network labeled DO_NOT_RESOLVE, then don't return IPs with that network
  3. 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.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions