【发布时间】:2016-07-20 01:20:14
【问题描述】:
我的项目是这样设置的:
./ -
Dockerfile
package.json
build
compiled files from frontend and backend directories get put here
backend
app.js
frontend
frontend files...
scripts
startServer.sh
build.sh
startServer.sh:
docker build ../ --tag myImage
# The build script compiles all my assets and places
# them in the top level 'build' directory which i am
# trying to link to my docker image so I can recompile
# on each file change and have the changes show in the docker image.
./build.sh
docker run --volume /path/to/build/dir:/src/app myImage
Dockerfile:
FROM node:4.4.7
RUN ls src/app
当调用 startServer 脚本中的构建命令时,Dockerfile 中的 RUN 命令给了我这个错误:
ls: cannot access src/app: No such file or directory
如果我将 RUN 更改为 CMD,它不会出错。此外,即使在构建给出该错误之后,它也会完成构建并且 docker run 命令没有给出错误。
“docker build”命令是否真的试图将“build”文件夹添加到启动容器的映像中?还是只是编译一些命令供图像制作时使用?
如果是后者,如何使一个 Dockerfile 既可用于构建又可用于两种情况下的运行?
我觉得我可能遗漏了 Docker 的一个关键概念,但我浏览了教程和文档并无法解决这个问题。
【问题讨论】:
标签: node.js docker build compilation