Dockerfile 找不到我的包含之一
Dockerfile not finding one of my includes
Docker 的新手并一直在检查文档,但似乎这是一个合理的 Docker 文件。
我是 运行 以下 Docker 文件,但遇到了一些问题:
FROM iojs:onbuild
COPY ../../webserver/includes/masterconfig.js ../../webserver/includes/masterconfig.js
这可能是菜鸟犯的错误,但非常感谢您的帮助:)
docker build -t nearby-pushes .
Sending build context to Docker daemon 9.728 kB
Sending build context to Docker daemon
Step 0 : FROM iojs:onbuild
# Executing 3 build triggers
Trigger 0, COPY package.json /usr/src/app/
Step 0 : COPY package.json /usr/src/app/
---> Using cache
Trigger 1, RUN npm install
Step 0 : RUN npm install
---> Using cache
Trigger 2, COPY . /usr/src/app
Step 0 : COPY . /usr/src/app
---> 5f4c87e2362c
Removing intermediate container 16a8fb4b4be1
Step 1 : COPY ../../webserver/includes/masterconfig.js ../../webserver/includes/masterconfig.js
INFO[0010] ../../webserver/includes/masterconfig.js: no such file or directory
ADD
and COPY
指令看不到父目录中的文件。
换句话说,您不能将它们与以 ../
.
开头的文件路径一起使用
来自 Docker 文档:
The path must be inside the context of the build; you cannot ADD ../something /something, because the first step of a docker build is to send the context directory (and subdirectories) to the docker daemon.
和
The path must be inside the context of the build; you cannot COPY ../something /something, because the first step of a docker build is to send the context directory (and subdirectories) to the docker daemon.
重要的词是构建的上下文。来自 docker build 文档:
Builds Docker images from a Dockerfile and a “context”. A build’s context is the files located in the specified PATH or URL. The build process can refer to any of the files in the context. For example, your build can use an ADD instruction to reference a file in the context.
错误显示在您的目录中找不到masterconfig.js。尽量使用绝对目录,dst目录也使用绝对目录,如/masterconfig.js 例如
FROM iojs:onbuild
COPY absolutepath/webserver/includes/masterconfig.js /masterconfig.js
或者确保 dst 目录存在,
CMD mkdir -p /webserver/includes
COPY absolutepath/webserver/incldues/masterconfig.js /webserver/incldues/maserconfig.js
Docker 的新手并一直在检查文档,但似乎这是一个合理的 Docker 文件。
我是 运行 以下 Docker 文件,但遇到了一些问题:
FROM iojs:onbuild
COPY ../../webserver/includes/masterconfig.js ../../webserver/includes/masterconfig.js
这可能是菜鸟犯的错误,但非常感谢您的帮助:)
docker build -t nearby-pushes .
Sending build context to Docker daemon 9.728 kB
Sending build context to Docker daemon
Step 0 : FROM iojs:onbuild
# Executing 3 build triggers
Trigger 0, COPY package.json /usr/src/app/
Step 0 : COPY package.json /usr/src/app/
---> Using cache
Trigger 1, RUN npm install
Step 0 : RUN npm install
---> Using cache
Trigger 2, COPY . /usr/src/app
Step 0 : COPY . /usr/src/app
---> 5f4c87e2362c
Removing intermediate container 16a8fb4b4be1
Step 1 : COPY ../../webserver/includes/masterconfig.js ../../webserver/includes/masterconfig.js
INFO[0010] ../../webserver/includes/masterconfig.js: no such file or directory
ADD
and COPY
指令看不到父目录中的文件。
换句话说,您不能将它们与以 ../
.
来自 Docker 文档:
The path must be inside the context of the build; you cannot ADD ../something /something, because the first step of a docker build is to send the context directory (and subdirectories) to the docker daemon.
和
The path must be inside the context of the build; you cannot COPY ../something /something, because the first step of a docker build is to send the context directory (and subdirectories) to the docker daemon.
重要的词是构建的上下文。来自 docker build 文档:
Builds Docker images from a Dockerfile and a “context”. A build’s context is the files located in the specified PATH or URL. The build process can refer to any of the files in the context. For example, your build can use an ADD instruction to reference a file in the context.
错误显示在您的目录中找不到masterconfig.js。尽量使用绝对目录,dst目录也使用绝对目录,如/masterconfig.js 例如
FROM iojs:onbuild
COPY absolutepath/webserver/includes/masterconfig.js /masterconfig.js
或者确保 dst 目录存在,
CMD mkdir -p /webserver/includes
COPY absolutepath/webserver/incldues/masterconfig.js /webserver/incldues/maserconfig.js