这个是需要证书导致无法连接,临时解决办法是设置 npm set strict-ssl=false
在 Dockerfile文件里的 RUN npm install 之前添加 RUN npm set strict-ssl=false
FROM node:12 # Create app directory WORKDIR /usr/src/app # Install app dependencies # A wildcard is used to ensure both package.json AND package-lock.json are copied # where available (npm@5+) COPY package*.json ./ RUN npm set strict-ssl=false RUN npm install # If you are building your code for production # RUN npm ci --only=production # Bundle app source COPY . . EXPOSE 8080 CMD [ "node", "server.js" ]
连接:
把一个 Node.js web 应用程序给 Docker 化 :https://nodejs.org/zh-cn/docs/guides/nodejs-docker-webapp/