Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
1.0k views
in Technique[技术] by (71.8m points)

node.js - docker npm install Error: getaddrinfo ENOTFOUND registry.npmjs.org registry.npmjs.org:443

I'm using docker version 1.10.1 on RHEL 7 and getting npm install error when using below Dockerfile. The Error: getaddrinfo ENOTFOUND registry.npmjs.org registry.npmjs.org:443. The same work with docker 1.91 on ubuntu 14.04. When I get bash and install inetutils-ping on container I noticed I can't ping anywhere

root@9deb4b274c1e:/home/nodexp#ping 8.8.8.8           
PING 8.8.8.8 (8.8.8.8): 56 data bytes
^C--- 8.8.8.8 ping statistics ---
4 packets transmitted, 0 packets received, 100% packet loss

Why is that ? Of course I can ping from RHEL

Dockerfile

FROM node:argon
# Create user nodexp in group nodexp
RUN groupadd -r nodexp 
    && useradd -m -r -g nodexp nodexp
WORKDIR /home/nodexp
# Install app dependencies
COPY package.json /home/nodexp
RUN npm install
# Bundle app source
COPY . /home/nodexp
EXPOSE 3000
CMD [ "npm", "start" ]

and package.json

{
  "name": "mp",
  "version": "0.0.0",
  "private": true,
  "scripts": {
    "start": "node app.js"
  },
  "dependencies": {
    "express": "~4.13.1"

  }
}
See Question&Answers more detail:os

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Reply

0 votes
by (71.8m points)

restarting docker with this command fixes it for me but I don't know why

sudo service docker restart


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
OGeek|极客中国-欢迎来到极客的世界,一个免费开放的程序员编程交流平台!开放,进步,分享!让技术改变生活,让极客改变未来! Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...