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
• 17,150 points
1,928 views
Check your DNS nameserver

2 answers to this question.

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
• 46,070 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,920 points
117 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,310 points
36 views
0 votes
1 answer

How to create a user-defined Bridge network in docker?

To create a user-defined bridge network, one ...READ MORE

answered Jul 3 in Docker by Sirajul
• 41,000 points
154 views
0 votes
1 answer
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
• 46,070 points
239 views
0 votes
1 answer