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
 # Move files under current directory to app directory
 ADD . /app/
 # Enter the app directory, similar to cd
 # 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   ...
 8.9-alpine: Pulling from
 605ce1bd3f31: Pull complete
 79b85b1676b5: Pull complete
 20865485d0c2: Pull complete
 Digest: sha256:6bb963d58da845cf66a22bc5a48bb8c686f91d30240f0798feb0d61a2832fc46
 Status: Downloaded newer image for
 ---> 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 failed, reason: getaddrinfo EAI_AGAIN
 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
 WORKDIR /usr/src/app
 ENV TZ Asia/Shanghai
 ARG registry=
 ARG disturl=
 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