Npm cannot always be installed after a mirror is built with Dockerfile

  docker, question

Dockerfile file:

# Version node Mirror
 FROM node:8.9-alpine
 
 # Author of Statement
 MAINTAINER test
 
 # Move files under current directory to app directory
 ADD . /app/
 
 # Enter the app directory, similar to cd
 WORKDIR /app
 
 # Installation Dependency
 RUN npm install
 
 # Exposed Ports
 EXPOSE 3000
 
 # Program Start Script
 CMD ["npm", "start"]

Perform mirror builddocker build -t docker_demo .After the command:

[root@cd56723212387 testnodejs]# 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]#

Let’s see why

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