Dockerfile中在运行npm install时出现错误

4

我将运行Docker build,使用Dockerfile来构建镜像。但是在npm install时出现错误:

Dockerfile:

# Download Runnable-web Repo
RUN eval $(ssh-agent) > /dev/null && ssh-add /.ssh/id_rsa && git clone git@github.com:CodeNow/runnable-web.git 

WORKDIR runnable-web 
RUN npm install 
RUN bower install  --allow-root

错误:

Step 5 : RUN npm install
 ---> Running in 3fefdf5af71d
npm ERR! install Couldn't read dependencies
npm ERR! Error: ENOENT, open '/runnable-web/package.json'
 If you need help, you may report this log at:
     <http://github.com/isaacs/npm/issues>
 or email it to:
     <npm-@googlegroups.com>

 Linux 3.13.0-24-generic
 "/usr/local/bin/node" "/usr/local/bin/npm" "install"

https://dev59.com/PXzaa4cB1Zd3GeqPUMNF - Sandip Singh
https://dev59.com/FV_Va4cB1Zd3GeqPRTtS - Sandip Singh
你确定git命令将repo克隆到/runnable-web/目录中吗?对我来说,这个错误看起来像是文件没有找到(但它在git repo的根目录中存在),所以也许你没有克隆到正确的目录。尝试将你的WORKDIR命令移到RUN之上? - Jay Dorsey
1个回答

0

我在共享驱动器 C:\ 下尝试了一下,结果出现了与你的一样的错误。

enter image description here

然后我将 Dockerfile 移动到子目录中,例如 C:\Intel 并进入该目录运行 docker build .,它可以正常工作。

enter image description here

所以我猜测Dockerfile不应该放在共享驱动器根目录下。


网页内容由stack overflow 提供, 点击上面的
可以查看英文原文,
原文链接