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)
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.
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.