[英]docker-compose not copying files into tmp folder to create container
I have a container for a Telegram bot running in a docker container which is being built via following Dockerfile:我有一个运行在 docker 容器中的 Telegram 机器人容器,该容器是通过以下 Dockerfile 构建的:
FROM debian:stretch
RUN apt-get -qq update && apt-get -qq install -y g++ make binutils cmake libssl-dev libboost-sysstem-dev libcurl4-openssl-dev zlib1g-dev
WORKDIR /usr/src/tgbot-cpp
COPY include include
COPY src src
COPY CMakeLists.txt ./
RUN cmake .
# ...
The Dockerfile is placed in /home/me/docks/tbot/Dockerfile
. Dockerfile 放在/home/me/docks/tbot/Dockerfile
中。
However, now when I want to organize the files a bit, ie, put the include
, src
, and CMakeLists.txt
into a subfolder called containerBuildFiles
(absolute: home/me/docks/tbot/containerBuildFiles
), I do the following:但是,现在当我想稍微整理一下文件时,即将include
、 src
和CMakeLists.txt
放入名为containerBuildFiles
的子文件夹中(绝对: home/me/docks/tbot/containerBuildFiles
),我执行以下操作:
docker-compose down
呼叫docker-compose down
Dockerfile
:编辑Dockerfile
:# ...
[-] COPY include include
[-] COPY src src
[-] COPY CMakeLists.txt ./
[+] COPY containerBuildFiles ./
# ...
mkdir containerBuildFiles
mv -t containerBuildFiles include src CMakeLists.txt
docker-compose build --no-cache --force-rm --pull
(只是为了确保) docker-compose build --no-cache --force-rm --pull
Which gives me following output:这让我关注 output:
[...]
Step 5/8 : COPY containerBuildFiles ./
ERROR: Service 'tgbot' failed to build: COPY failed: stat /home/docker/tmp/docker-builder654813864/containerBuildFiles: no such file or directory
Now when I'm undoing the changes made in the Dockerfile
and in the directory structure, everything is working fine again.现在,当我撤消在Dockerfile
和目录结构中所做的更改时,一切正常。
I have also tried changing the path in the Dockerfile
from containerBuildFiles
to ./containerBuildFiles
resp.我还尝试将Dockerfile
中的路径从containerBuildFiles
更改为./containerBuildFiles
。 /home/me/docks/tbot/containerBuildFiles
(I know it's bad practice but I wanted to try it) or simply running docker build. -t tbot_test --no-cache
/home/me/docks/tbot/containerBuildFiles
(我知道这是不好的做法,但我想尝试一下)或者只是运行docker build. -t tbot_test --no-cache
docker build. -t tbot_test --no-cache
, same results. docker build. -t tbot_test --no-cache
,结果相同。
My idea was that maybe the docker-compose context is not being updated correctly.我的想法是 docker-compose 上下文可能没有正确更新。 Apparently the files from the docker container are not being copied to the /home/docker/tmp
folder correctly.显然 docker 容器中的文件未正确复制到/home/docker/tmp
文件夹。
So now my question is: how can I update the docker-compose context so updated folders will be passed to creation of docker containers correctly again?所以现在我的问题是:如何更新 docker-compose 上下文,以便更新的文件夹将再次正确地传递给 docker 容器的创建?
Any help is greatly appreciated.任何帮助是极大的赞赏。
Solved it by removing .dockerignore
file.通过删除.dockerignore
文件解决了这个问题。
[EDIT] Reason: the .dockerignore
file included lines which ignore every folder that was not include
, src
or the file CMakeLists.txt
: [编辑] 原因: .dockerignore
文件包含的行忽略了不include
的每个文件夹, src
或文件CMakeLists.txt
:
!include
!src
!CMakeLists.txt
so they were not copied.所以他们没有被复制。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.