简体   繁体   中英

NPM install always fails to fetch NPM registry in Docker container at random times

We has setted up continuous integration/deployment on a Node.js web application. The problem is, when the pipeline runs tests in a docker container on the CI server (GitLab CI), npm install fails at random times. The container uses node v5.0.0 and npm v3.3.6. The output of the NPM install is:

npm info retry will retry, error on last attempt: Error: getaddrinfo ENOTFOUND registry.npmjs.org registry.npmjs.org:443
npm info retry will retry, error on last attempt: Error: getaddrinfo ENOTFOUND registry.npmjs.org registry.npmjs.org:443
npm info attempt registry request try #3 at 4:39:19 PM
npm http fetch GET https://registry.npmjs.org/commander/-/commander-2.8.1.tgz
npm info attempt registry request try #3 at 4:39:19 PM
npm http fetch GET https://registry.npmjs.org/source-map/-/source-map-0.4.4.tgz
npm ERR! fetch failed https://registry.npmjs.org/commander/-/commander-2.8.1.tgz
npm WARN retry will retry, error on last attempt: Error: getaddrinfo ENOTFOUND registry.npmjs.org registry.npmjs.org:443
npm ERR! fetch failed https://registry.npmjs.org/source-map/-/source-map-0.4.4.tgz
npm WARN retry will retry, error on last attempt: Error: getaddrinfo ENOTFOUND registry.npmjs.org registry.npmjs.org:443
npm info retry fetch attempt 3 at 4:40:27 PM
npm info attempt registry request try #1 at 4:40:27 PM
npm http fetch GET https://registry.npmjs.org/commander/-/commander-2.8.1.tgz
npm info retry fetch attempt 3 at 4:40:27 PM
npm info attempt registry request try #1 at 4:40:27 PM
npm http fetch GET https://registry.npmjs.org/source-map/-/source-map-0.4.4.tgz
npm info retry will retry, error on last attempt: Error: getaddrinfo ENOTFOUND registry.npmjs.org registry.npmjs.org:443
npm info retry will retry, error on last attempt: Error: getaddrinfo ENOTFOUND registry.npmjs.org registry.npmjs.org:443
npm info attempt registry request try #2 at 4:40:45 PM
npm http fetch GET https://registry.npmjs.org/source-map/-/source-map-0.4.4.tgz
npm info attempt registry request try #2 at 4:40:45 PM
npm http fetch GET https://registry.npmjs.org/commander/-/commander-2.8.1.tgz
npm info retry will retry, error on last attempt: Error: getaddrinfo ENOTFOUND registry.npmjs.org registry.npmjs.org:443
npm info retry will retry, error on last attempt: Error: getaddrinfo ENOTFOUND registry.npmjs.org registry.npmjs.org:443
npm info attempt registry request try #3 at 4:41:53 PM
npm http fetch GET https://registry.npmjs.org/source-map/-/source-map-0.4.4.tgz
npm info attempt registry request try #3 at 4:41:53 PM
npm http fetch GET https://registry.npmjs.org/commander/-/commander-2.8.1.tgz
npm ERR! fetch failed https://registry.npmjs.org/source-map/-/source-map-0.4.4.tgz
npm ERR! fetch failed https://registry.npmjs.org/commander/-/commander-2.8.1.tgz
npm ERR! Linux 3.16.0-4-amd64
npm ERR! argv "/usr/local/bin/node" "/usr/local/bin/npm" "install"
npm ERR! node v5.0.0
npm ERR! npm  v3.3.6
npm ERR! code ENOTFOUND
npm ERR! errno ENOTFOUND
npm ERR! syscall getaddrinfo

npm ERR! network getaddrinfo ENOTFOUND registry.npmjs.org registry.npmjs.org:443
npm ERR! network This is most likely not a problem with npm itself
npm ERR! network and is related to network connectivity.
npm ERR! network In most cases you are behind a proxy or have bad network settings.
npm ERR! network 
npm ERR! network If you are behind a proxy, please make sure that the
npm ERR! network 'proxy' config is set properly.  See: 'npm help config'

I can see that npm cannot fetch 2 times out of 3, so it seems like a network issue, but the CI server is running on Compute Engine (I have faith in Google and NPM registry connection...). So I just tried to restart my Docker service, but it did not work either.

Any ideas about it ? Thanks in advance !

Edit: There was a wide-scale DNS outage this day (21/10/16), could it be the origin of the problem ? It would also explain why an other build of an other project has failed at the deployment step shortly after. See https://www.wired.com/2016/10/internet-outage-ddos-dns-dyn/

It turned out that there was a wide-scale DNS outage this day that caused my builds to fail. See https://www.wired.com/2016/10/internet-outage-ddos-dns-dyn/

Check whether VPN is on. In most of the cases VPN causes this issue. Disconnect from VPN and then try again it would work.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM