简体   繁体   English

NPM 安装总是无法随机获取 Docker 容器中的 NPM 注册表

[英]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.我们已经在 Node.js Web 应用程序上设置了持续集成/部署。 The problem is, when the pipeline runs tests in a docker container on the CI server (GitLab CI), npm install fails at random times.问题是,当管道在 CI 服务器 (GitLab CI) 上的 docker 容器中运行测试时,npm install 会随机失败。 The container uses node v5.0.0 and npm v3.3.6.容器使用 node v5.0.0 和 npm v3.3.6。 The output of the NPM install is: NPM 安装的输出是:

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...).我可以看到 npm 无法获取 3 次中的 2 次,所以这似乎是一个网络问题,但是 CI 服务器正在 Compute Engine 上运行(我相信 Google 和 NPM 注册表连接......)。 So I just tried to restart my Docker service, but it did not work either.所以我只是尝试重新启动我的 Docker 服务,但它也不起作用。

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 ?编辑:今天(2016 年 10 月 21 日)发生了大规模的 DNS 中断,这可能是问题的根源吗? 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/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.事实证明,今天发生了大规模的 DNS 中断,导致我的构建失败。 See https://www.wired.com/2016/10/internet-outage-ddos-dns-dyn/https://www.wired.com/2016/10/internet-outage-ddos-dns-dyn/

Check whether VPN is on.检查 VPN 是否开启。 In most of the cases VPN causes this issue.在大多数情况下,VPN 会导致此问题。 Disconnect from VPN and then try again it would work.断开与 VPN 的连接,然后再试一次,它会起作用。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

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