dockerfiles-windows: npm install error - getaddrinfo EAI_AGAIN registry.npmjs.org:443

Everytime I try to npm install a file I get the following error: getaddrinfo EAI_AGAIN registry.npmjs.org:443

I am using stefanscherer/node-windows:8.9.3 image but have had this issue with many other images as well.

Initial npm error: npm-error

npm logs: npm-error-2

About this issue

  • Original URL
  • State: closed
  • Created 9 years ago
  • Comments: 35 (3 by maintainers)

Most upvoted comments

This known issue for Docker and 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.

I couldn’t resolve issue with adding DNS setting to docker daemon, but I found another solution (maybe this will be useful for someone) - just use host network to resolve dns names by adding --network host setting, ex.: docker build . --network host -t mytag ...

I got a server network issue, and a client restart to let me ssh, and the problem happened. I’ll show my steps to slove this issue, hope it help someone 😄

  1. Follow the dns modification step above.
  2. sudo service docker restart or sudo systemctl restart docker to restart docker.
  3. sloved (maybe).

Restarting system resolved my issue.

/etc/docker/daemon.json do not work for me. I have to reboot my ubuntu server to resolve my problem.

This known issue for Docker and 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.

Yes! It worked! Thank you!

I couldn’t resolve issue with adding DNS setting to docker daemon, but I found another solution (maybe this will be useful for someone) - just use host network to resolve dns names by adding --network host setting, ex.: docker build . --network host -t mytag ...

worked for me 😊

I had the same issue on WSL2 Ubuntu, @binarymist solution worked.

This known issue for Docker and 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.

Worked for me.

hey guys,

i run Docker 24.0.7 on Ubuntu 22.04.3 LTS. i tried installing express module on a Node.js container (docker run -v $PWD:/app -w /app node npm install express) but it failed with the same errors.

weird but… a restart solved my problem too!!!

could be related to any port mapping i run before that with Nginx container (docker run -p 8080:80 -v $PWD:/usr/share/nginx/html nginx) i saw it created a FW rule on my Ubuntu

docker-node-error-01

This known issue for Docker and 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.

This works for me. Thanks a lot dude.

I couldn’t resolve issue with adding DNS setting to docker daemon, but I found another solution (maybe this will be useful for someone) - just use host network to resolve dns names by adding --network host setting, ex.: docker build . --network host -t mytag ...

This one worked for me! Thank you

I couldn’t resolve issue with adding DNS setting to docker daemon, but I found another solution (maybe this will be useful for someone) - just use host network to resolve dns names by adding --network host setting, ex.: docker build . --network host -t mytag ...

You just saved me severally days of headache.

I couldn’t resolve issue with adding DNS setting to docker daemon, but I found another solution (maybe this will be useful for someone) - just use host network to resolve dns names by adding --network host setting, ex.: docker build . --network host -t mytag ...

This solved my issue on Fedora 32.

@karanvij-ai Seeing the same issue, were you able to find a fix?

Hi All,

I am running Docker Toolbox on windows 10 home.

Following were the steps(In Docker console -> Docker Quick Start and using bash from git installation):

  1. npm install -g create-react-app
  2. create-react-app frontend
  3. cd frontend
  4. npm run test
  5. npm run build 6.npm run start
  6. code .

Created docker file(Dockerfile.dev):

FROM node:alpine

WORKDIR ‘/app’

COPY package.json .

RUN npm install

COPY . .

CMD [“npm”, “run”, “start”]

$ docker build -f Dockerfile.dev .

Output in console:

Sending build context to Docker daemon 146.5MB Step 1/6 : FROM node:alpine —> ef7d474eab14 Step 2/6 : WORKDIR ‘/app’ —> Using cache —> c47b0eb2c3c1 Step 3/6 : COPY package.json . —> Using cache —> e5c66b740c8b Step 4/6 : RUN npm install —> Running in 962746bea142 npm ERR! code EAI_AGAIN npm ERR! errno EAI_AGAIN npm ERR! request to https://registry.npmjs.org/react failed, reason: getaddrinfo EAI_AGAIN registry.npmjs.org

npm ERR! A complete log of this run can be found in: npm ERR! /root/.npm/_logs/2019-09-21T01_00_35_350Z-debug.log The command ‘/bin/sh -c npm install’ returned a non-zero code: 1

Also, I couldn’t find the complete log, not sure where is location.

Please help, Thanks