TEL:400-8793-956
当前位置:开发工具

使用dockerfile生成映像后,无法安装NPM

提问者: 近期获赞: 浏览人数: 发布时间:2021-03-16 08:32:37

 问:Dockerfile文件:

 
#Make the version of the node image
FROM node:8.9-alpine
 
#Statement author
MAINTAINER test
 
#Move the files under the current directory to the app directory
ADD . /app/
 
#Enter the app directory, similar to CD
WORKDIR /app
 
#Installation dependency
RUN npm install
 
#Exposed ports
EXPOSE 3000
 
#Program startup script
CMD ["npm", "start"]
执行镜像构建docker build -t docker_demo。在命令之后:
 
[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]# 
让我们看看为什么
 
 
答:完整的执行报告以下错误:solutionSend将构建上下文发送到Docker守护程序30.72 kB步骤1/13:FROM节点:10 —> 0e2811757f93步骤2/13:MAINTAINER 1265218242 @ qq。COM - >使用高速缓存- > 0f56641845d4Step 3/13:WORKDIR / usr / src目录/应用程序- >使用高速缓存- > 3cd4d2fea9ccStep 4/13:ENV TZ亚洲/上海- >使用高速缓存- > 3ee9ede07cecStep 5/13:ARG注册表= HTTPS ://registry.npm.taobao.org- >使用缓存-> dbc95fba9e53步骤6/13:ARG disturl = https://npm.taobao.org/dist—>使用缓存—> 750108b89d75步骤7/13:运行纱线配置集disturl $ disturl —>使用缓存—> 42c4b56000eb步骤8/13:运行纱线配置集注册表$ registry —>使用缓存—> 9d850c17c68a步骤9/13:COPY包。 json / usr / src / app / —>使用缓存—> 7a42e1eeb6f0步骤10/13:RUN yarn –frozen-lockfile –production —>在e943bf260aef
yarn install v1.9.2warning package.json中运行:找不到许可证fieldinfo找不到锁文件。webTest@1.0.0 :无许可证字段[1/4]正在解决软件包…错误发生意外错误:“ https://registry.npm.taobao.org/express:ETIMEDOUT” .info如果您认为这是一个错误,请使用“ /usr/src/app/yarn-error.log”中提供的信息打开错误报告。info访问https://yarnpkg.com/en/docs/c…有关此命令的文档。^ C [ root @ xs16788177135 mynodejs3]#vi Dockerfile [ root @ xs16788177135 mynodejs3]#docker build -t docker_demo。将构建上下文发送到Docker守护程序30.72 kB步骤1/13:FROM节点:10-> 0e2811757f93步骤2/13:MAINTAINER xialeistudio xialeistudio@gmail.com- >在1e3ae330844c中运行-> ce8f37d8a31e删除中间容器1e3ae330844c步骤3/13 / usr:WORKDIR / app —> 295c25c9c1d2删除中间容器f4783c265305步骤4/13:ENV TZ Asia / Shanghai —>在5a958374fc2c中运行-> e5a75e375035删除中间容器5a958374fc2c步骤5/13:ARG注册中心= https://registry.npm.taobao.org->在e4c5f37fd86e中运行-> 55f15772b14f删除中间容器e4c5f37fd86e步骤6/13:ARG disturl = https://npm.taobao.org/dist —>在7be97419dbc7中运行-> 579e2f7ac785删除中间容器7be97419dbc7RUN $ 7/13 disturl —>运行在7364ec8dbdf5
yarn config v1.9.2success中将“ disturl”设置为“ https://npm.taobao.org/dist”。完成时间为0.05秒。—> ed99f64c40aa删除中间容器7364ec8dbdf5步骤8/13:运行yarn config设置注册表$ registry —>在89b712aea8f7中运行
yarn config v1.9.2成功将“ registry”设置为“ https://registry.npm.taobao.org”。完成时间为0.06s。—> e4dcff4d0e85删除中间容器89b712aea8f7步骤9/13:COPY package.json / usr / src / app / —> 271167d932bc删除中间容器59446e499b51步骤10/13:运行yarn –冻结锁文件–生产—>在e70b4a2c701e
yarn install v1.9中运行。package.json:找不到许可证字段信息。找不到锁文件。[1/4]解决软件包…警告webTest@1.0.0 :找不到许可证字段信息如果您认为这是一个错误,请使用“ / usr”中的信息打开一个错误报告。 /src/app/yarn-error.log”.info访问https://yarnpkg.com/en/docs/c…有关此命令的文档。错误发生意外错误:“ https://registry.npm.taobao.org/express:ETIMEDOUT”。命令'/ bin / sh -c yarn –frozen-lockfile –production'返回了非零代码:1
上一篇: Chrome插件无法在离线页面上运行(文件:/ / *)?如何启动插件?
下一篇: 如何为Android创建私有库?