Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

DNS queries inside docker fail with Error: getaddrinfo EAI_AGAIN #32106

Closed
tkandal opened this issue Mar 25, 2017 · 13 comments
Closed

DNS queries inside docker fail with Error: getaddrinfo EAI_AGAIN #32106

tkandal opened this issue Mar 25, 2017 · 13 comments

Comments

@tkandal
Copy link

tkandal commented Mar 25, 2017

We are using Bamboo to build a complete docker container with a NodeJS application.
During building the docker is started and npm is used to download all the depending
frameworks. The build fails because it seems like some of the DNS queries fail with
getaddrinfo EAI_AGAIN registry.npmjs.org:443

Has anyone experienced the same problem?

...
25-mar-2017 09:06:14	npm info using npm@3.10.10
25-mar-2017 09:06:14	npm info using node@v6.9.5
...
25-mar-2017 09:07:24	npm info retry will retry, error on last attempt: Error: getaddrinfo EAI_AGAIN registry.npmjs.org:443
...
25-mar-2017 09:08:24	npm http request GET https://registry.npmjs.org/supertest
25-mar-2017 09:08:29	npm ERR! Linux 4.4.0-66-generic
25-mar-2017 09:08:29	npm ERR! argv "/usr/local/bin/node" "/usr/local/bin/npm" "install"
25-mar-2017 09:08:29	npm ERR! node v6.9.5
25-mar-2017 09:08:29	npm ERR! npm  v3.10.10
25-mar-2017 09:08:29	npm ERR! code EAI_AGAIN
25-mar-2017 09:08:29	npm ERR! errno EAI_AGAIN
25-mar-2017 09:08:29	npm ERR! syscall getaddrinfo
25-mar-2017 09:08:29	
25-mar-2017 09:08:29	npm ERR! getaddrinfo EAI_AGAIN registry.npmjs.org:443
25-mar-2017 09:08:29	npm ERR! 
25-mar-2017 09:08:29	npm ERR! If you need help, you may report this error at:
25-mar-2017 09:08:29	npm ERR!     <https://github.com/npm/npm/issues>
25-mar-2017 09:08:29	
25-mar-2017 09:08:29	npm ERR! Please include the following file with any support request:
25-mar-2017 09:08:29	npm ERR!     /app/npm-debug.log
25-mar-2017 09:08:29	The command '/bin/sh -c npm install' returned a non-zero code: 1
25-mar-2017 09:08:29	
...
@justincormack
Copy link
Contributor

justincormack commented Mar 25, 2017 via email

@jubajuba
Copy link

Ignore this problem.
The build server had net.ipv4.ip_forward = 0 in /etc/sysctl.conf so the build could not reach the internet.

@tkandal
Copy link
Author

tkandal commented Mar 25, 2017

The server was patched without my knowledge and the patching modified /etc/sysctl.conf.
Sorry for the disturbance. Close this issue.

@binarymist
Copy link

This known issue is discussed in detail here: https://development.robinwinslow.uk/2016/06/23/fix-docker-networking-dns/

Simple fix is to create the file /etc/docker/daemon.json

and insert:

{
    "dns": ["10.0.0.2", "8.8.8.8"]
}

where 10.0.0.2 is the first DNS server your machine requests records from, and 8.8.8.8 is the fallback DNS server, google in this case.

@donquixote
Copy link

For me it helped to run "docker-compose up -d" again. The problem was the old docker instance was created in a different session with a different wifi network etc.

@xDroni
Copy link

xDroni commented Nov 11, 2020

If you are using VPN and docker has problems with DNS try:

  1. Connect to VPN
  2. cat /etc/resolv.conf
  3. Copy generated DNSes
  4. Insert copied DNSes into /etc/docker/daemon.json as follows:
{
    "dns": ["a1.a2.a3.a4", "b1.b2.b3.b4"]
}
  1. sudo service docker restart

This worked for me.

@sovereignstack
Copy link

This known issue is discussed in detail here: https://development.robinwinslow.uk/2016/06/23/fix-docker-networking-dns/

Simple fix is to create the file /etc/docker/daemon.json

and insert:

{
    "dns": ["10.0.0.2", "8.8.8.8"]
}

where 10.0.0.2 is the first DNS server your machine requests records from, and 8.8.8.8 is the fallback DNS server, google in this case.

Didn't work for me. The DNS in /etc/resolv.conf comes from DHCP and is managed by the cloud service provider. It doesn't/wouldn't contain the DNS records of docker containers.

When I did docker container inspect mycontainer, it was shown as connected to the docker network I had created
but when I did docker network inspect mynetwork, the container was not shown as being connected to the network.

I tried docker network connect mynetwork mycontainer. It didn't help.

Restarting the container solved the problem.

@hayyaun
Copy link

hayyaun commented Aug 24, 2022

In my case removing "iptables": false from /etc/docker/daemon.json fixed the problem. I was using this because docker iptables were messing ports closed by ufw and made by nginx. So I don't know what to do now... seems like whenever I want to install a new dep I have to enable and disable it back again.

@melroy89
Copy link

For me it helped to run "docker-compose up -d" again. The problem was the old docker instance was created in a different session with a different wifi network etc.

So I have multiple Docker images using NodeJS (based on node:lts-alpine). All those docker containers has this "getaddrinfo issue", but only right after a system reboot. Restarting those specific docker containers indeed solve the issue temporally.
But the (VERY HIGH) likelihood it fails again after a system reboot is still present until today.

I would like to solve this problem once and for all. My guess is there is a network dependency issue in Docker or within NodeJS docker image. Either way maybe the app in the docker container is trying to access the internet before the network is up? Or!? Help me.. This issue is causing 3 years of brain pain for me.

@cedced19
Copy link

cedced19 commented Jan 13, 2023

@Danger89 The remark from Melroy van den Berg on this Stack Overflow thread can help you : https://stackoverflow.com/a/61955468
EDIT: Sorry I didn't know it was actually you.

@melroy89
Copy link

@Danger89 The remark from Melroy van den Berg on this Stack Overflow thread can help you : https://stackoverflow.com/a/61955468 EDIT: Sorry I didn't know it was actually you.

Who is Melroy? Hahah. Yea it's me. 🤣

@bgfernandes
Copy link

If you are using VPN and docker has problems with DNS try:

  1. Connect to VPN
  2. cat /etc/resolv.conf
  3. Copy generated DNSes
  4. Insert copied DNSes into /etc/docker/daemon.json as follows:
{
    "dns": ["a1.a2.a3.a4", "b1.b2.b3.b4"]
}
  1. sudo service docker restart

This worked for me.

This, this is what I came here for. Thank you kind sir.

@paulosouzainfo
Copy link

In my case removing "iptables": false from /etc/docker/daemon.json fixed the problem. I was using this because docker iptables were messing ports closed by ufw and made by nginx. So I don't know what to do now... seems like whenever I want to install a new dep I have to enable and disable it back again.

i can't understanding this issue origin, but works perfectly. thanks!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests