After building an image with Dockerfile, npm always fails to install

Dockerfile file:

-sharpnode
FROM node:8.9-alpine

-sharp
MAINTAINER test

-sharpapp
ADD . /app/

-sharpappcd
WORKDIR /app

-sharp
RUN npm install

-sharp
EXPOSE 3000

-sharp
CMD ["npm", "start"]

after executing docker build-t docker_demo. command:

[root@cd56723212387 testnodejs]-sharp docker build -t docker_demo .
Sending build context to Docker daemon 17.92 kB
Step 1/7 : FROM node:8.9-alpine
Trying to pull repository docker.io/library/node ... 
8.9-alpine: Pulling from docker.io/library/node
605ce1bd3f31: Pull complete 
79b85b1676b5: Pull complete 
20865485d0c2: Pull complete 
Digest: sha256:6bb963d58da845cf66a22bc5a48bb8c686f91d30240f0798feb0d61a2832fc46
Status: Downloaded newer image for docker.io/node:8.9-alpine
 ---> 406f227b21f5
Step 2/7 : MAINTAINER test
 ---> Running in 641a6df02500
 ---> c957a05f33c1
Removing intermediate container 641a6df02500
Step 3/7 : ADD . /app/
 ---> ba5d7c9c701d
Removing intermediate container 52c5456d5f6d
Step 4/7 : WORKDIR /app
 ---> 7fc86e6854d1
Removing intermediate container c2a6af1b18fd
Step 5/7 : RUN npm install
 ---> Running in c715c3318df3

**npm ERR! code EAI_AGAIN
npm ERR! errno EAI_AGAIN
npm ERR! request to https://registry.npmjs.org/express failed, reason: getaddrinfo EAI_AGAIN registry.npmjs.org:443
npm ERR! A complete log of this run can be found in:
npm ERR!     /root/.npm/_logs/2018-08-07T01_25_32_257Z-debug.log
The command "/bin/sh -c npm install" returned a non-zero code: 1**
[root@cd56723212387 testnodejs]-sharp 

everybody, let"s see what the reason is

.
Apr.05,2021

FROM node:10
MAINTAINER xialeistudio xialeistudio@gmail.com
WORKDIR /usr/src/app
ENV TZ Asia/Shanghai
ARG registry=https://registry.npm.taobao.org
ARG disturl=https://npm.taobao.org/dist
RUN yarn config set disturl $disturl
RUN yarn config set registry $registry
COPY package.json /usr/src/app/
RUN yarn --frozen-lockfile --production
COPY . /usr/src/app
EXPOSE 8080
CMD [ "yarn", "start:prod" ]

take away


solved many detours,

the correct solution is as follows:
dns change to Ali's DNS:223.5.5.5 or 223.6.6.6
and then restart service network restart


Network problem, unable to access npmjs.org site

MySQL Query : SELECT * FROM `codeshelper`.`v9_news` WHERE status=99 AND catid='6' ORDER BY rand() LIMIT 5
MySQL Error : Disk full (/tmp/#sql-temptable-64f5-1b39801-2c195.MAI); waiting for someone to free some space... (errno: 28 "No space left on device")
MySQL Errno : 1021
Message : Disk full (/tmp/#sql-temptable-64f5-1b39801-2c195.MAI); waiting for someone to free some space... (errno: 28 "No space left on device")
Need Help?