简体   繁体   English

docker-compose 未将文件复制到 tmp 文件夹以创建容器

[英]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:但是,现在当我想稍微整理一下文件时,即将includesrcCMakeLists.txt放入名为containerBuildFiles的子文件夹中(绝对: home/me/docks/tbot/containerBuildFiles ),我执行以下操作:

  • call docker-compose down呼叫docker-compose down
  • edit Dockerfile :编辑Dockerfile
# ...
 [-] COPY include include
 [-] COPY src src
 [-] COPY CMakeLists.txt ./
 [+] COPY containerBuildFiles ./
# ...
  • mkdir containerBuildFiles
  • mv -t containerBuildFiles include src CMakeLists.txt
  • (just to make sure) 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.

相关问题 Docker 组合卷:在执行 docker-compose 时将文件夹从 docker 容器复制到主机 - Docker compose volume: copying folder from docker container to host when executing docker-compose up 使用 Docker Compose 将文件复制到容器 - Copying files to a container with Docker Compose 为什么“ docker-compose run”可以在容器外部创建文件? - Why can “docker-compose run” create files outside the container? 使用docker-compose将Wiremock文件从本地复制到Docker容器 - Copying wiremock files from my local to Docker container using docker-compose docker-compose将文件复制为文件夹 - docker-compose copies files as folder 使用 Docker-compose 将文件复制到 Docker 容器中的 tomcat webapps 文件夹 - Copy files to the tomcat webapps folder in Docker container using Docker-compose Docker、docker-compose 和在项目之间复制文件 - Docker, docker-compose and copying files between projects Docker-compose 不会将测试文件从本地文件夹复制到容器中,而是复制其他所有内容 - Docker-compose doesn't copy Test files from local folder into Container , but copies everything else 为什么复制文件时我的 docker-compose 构建失败 - Why my docker-compose build is failing when copying files 如何将本地文件共享到docker容器中使用docker-compose进行swarm - How to share local files to docker container In swarm with docker-compose
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM