npm install returns connection timeout while building docker image npm install returns connection timeout while building docker image docker docker

npm install returns connection timeout while building docker image


In my case works with this steps:

  1. In the Host, I change Host Server/etc/sysctl.conf:

I added

net.ipv4.ip_forward=1
  1. I use

    nslookup registry.npmjs.org

Give me the IP 104.16.25.38

  1. Docker Build with IP

docker build . --add-host registry.npmjs.org:104.16.25.38 -t test


In my case works with this below single step,

docker build --add-host registry.npmjs.org:104.16.25.38 -t .