Docker Network Nginx Resolver

0 votes

I am trying to get rid of deprecated Docker links in my configuration. What's left is getting rid of those Bad Gateway nginx reverse proxy errors when I recreated a container.

I am using the following configuration snippet inside nginx:

location / {
      resolver 127.0.0.1 valid=30s;
      set $backend "http://confluence:8090";
      proxy_pass $backend;
  1. I started a container with hostname confluence on my Docker network with name nettest.
  2. Then I started the nginx container on network nettest.
  3. I can ping confluence from inside the nginx container
  4. confluence is listed inside the nginx container's /etc/hosts file
  5. nginx log says `send() failed (111: Connection refused) while resolving, resolver: 127.0.0.1:53``
  6. I tried the docker network default dns resolver 127.0.0.11 from /etc/resol.conf
  7. nginx log says confluence could not be resolved (3: Host not found)

Can someone explain how to configure nginx resolver with docker networks.

Aug 1, 2018 in Docker by Hannah
• 14,080 points
938 views
Check your DNS nameserver

2 answers to this question.

Your answer

Your name to display (optional):
Privacy: Your email address will only be used for sending these notifications.
0 votes

First off, you should be using the Docker embedded DNS server at 127.0.0.11.

The reason for your problem could be one of these

  1. nginx is trying to use IPv6 (AAAA record) for the DNS queries.

Something like:

http {

    resolver 127.0.0.11 ipv6=off;

}

This is probably no longer a problem with Docker 1.11:

Fix to not forward docker domain IPv6 queries to external servers (#21396)

  1. Take care that you don't accidentally override the resolver configuration directive. In my case I had in the server block resolver 8.8.8.8 8.8.4.4; from Mozilla's SSL Configuration Generator, which was overriding the resolver 127.0.0.11; in the httpblock. That had me scratching my head for a long time...
answered Aug 1, 2018 by Kalgi
• 35,720 points
Hey, I tried your solution, it's working for me. I am running nginx as a docker container inside Vagrant box. I cat /etc/resolv.conf .

nameserver 127.0.0.11

options ndots:0

It will be great if you help me
Can you please explain the issue you're facing in detail?
0 votes
I had the exact same error. Funny story, I used the wrong IP address of the nameserver.
answered May 7 by Pallavi

Related Questions In Docker

0 votes
1 answer

Docker Swarm Overlay Network Communication

Try to recreate network like this : docker ...READ MORE

answered Aug 22, 2018 in Docker by Nilesh
• 6,900 points
40 views
0 votes
1 answer

Docker For Windows error: network adapters down

For testing, you can use the alternative ...READ MORE

answered Sep 24, 2018 in Docker by Tyrion anex
• 8,280 points
14 views
+6 votes
4 answers

Error: Docker saying "bad file descriptor"

The solution was easy enough. Add these ...READ MORE

answered Mar 26, 2018 in Docker by DragonLord999
• 8,360 points
585 views
+2 votes
6 answers
0 votes
1 answer
0 votes
1 answer
0 votes
1 answer

Network timed out while trying to connect to https://index.docker.io

This happened because docker virtual machine gets ...READ MORE

answered Jul 27, 2018 in Docker by Kalgi
• 35,720 points
76 views
+4 votes
4 answers

How To Access a Service on Host From a Docker Container?

Adding to kalgi's answer, You can also ...READ MORE

answered Oct 16, 2018 in Docker by lina
• 8,100 points

edited Oct 16, 2018 by lina 1,925 views

© 2018 Brain4ce Education Solutions Pvt. Ltd. All rights Reserved.
"PMP®","PMI®", "PMI-ACP®" and "PMBOK®" are registered marks of the Project Management Institute, Inc. MongoDB®, Mongo and the leaf logo are the registered trademarks of MongoDB, Inc.