Enabling DNS Round Robin

I’d like to make use of the new feature in 1.11.0

Multiple A/AAAA records from embedded DNS Server for DNS Round robin (#21019)

I’ve got a minimal example with instructions but the DNS isn’t doing round robin.

My understanding is that DNS round robin can be enabled with a network alias like

    networks:
      backend:
        aliases:
          # All app servers be referred to by this alias with the backend network
          - apps

As you can see in this docker-compose.yml file.

Any app using the apps alias should be in a DNS round robin. So if I setup an nginx.conf file to use the apps alias I should see requests served by all app hosts.

However, in my example you can see the curl request always gets served by the same host.

Is there anything else I need to do to enable DNS round robin?

This happens on both Docker Toolbox 1.11.0 and Docker for Mac 1.11.0-beta7 (build: 5830)

I just tried following that same example:

git clone 'https://github.com/everett-toews/docker-dns-round-robin.git'
cd docker-dns-round-robin
docker-compose up -d
docker run --rm -it --net=dockerdnsroundrobin_backend azukiapp/dig dig apps.
docker-compose scale app=3
docker run --rm -it --net=dockerdnsroundrobin_backend azukiapp/dig dig apps.

(the azukiapp/dig image is one I found randomly on hub)

Before the scale, dig returned one address:

;; ANSWER SECTION:
apps.			600	IN	A	172.21.0.3

After the scale, it returned all three containers:

;; ANSWER SECTION:
apps.			600	IN	A	172.21.0.5
apps.			600	IN	A	172.21.0.3
apps.			600	IN	A	172.21.0.4

Since in my testing, I hit the nginx before I called scale, I ran into the same behavior that you did until I restarted the lb service with docker-compose restart lb. Then I was seeing responses from each container. Nginx will cache a DNS response for as long as the TTL. In this case, that is 600 seconds.

nginx can be configured to override this with a different value: http://nginx.org/en/docs/http/ngx_http_core_module.html#resolver

Thanks!

And if you use the valid param on resolver you override that caching period. I also got some friendly help over here. I updated my example and it’s working now. Cheers.