简体   繁体   English

无法将我的二进制文件从 docker build 的第一阶段复制到第二阶段

[英]Cannot copy my binary from first stage of docker build to second

I am using multi-stage build but something is not working as expected.我正在使用多阶段构建,但有些事情没有按预期工作。 The images are custom ones and we are having our own artifactory - so don't worry about the links, they are working.图像是自定义的,我们有自己的人工制品 - 所以不要担心链接,它们正在工作。

My simple Dockerfile is :我的简单Dockerfile是:

####################      BUILD Stage      ####################

FROM <url>/my-docker-image:latest AS build-image
COPY . /workarea
WORKDIR /workarea

## run the integration tests as well.

RUN INTEGRATION_TESTS=1 make docker

RUN pwd
RUN ls -l cmake-build/linux_64_static_make_Debug/src/
RUN ls -l cmake-build/linux_64_static_make_Debug/tests/

####################      RUN Stage      ####################

FROM <url>/my-test-image:latest AS run-tests-image

WORKDIR /workarea

COPY --from=build-image /workarea/cmake-build/linux_64_static_make_Debug/src/mybinary.tsk /workarea/cmake-build/linux_64_static_make_Debug/src/
COPY --from=build-image /workarea/cmake-build/linux_64_static_make_Debug/tests/unit/mybinary.t.tsk /workarea/cmake-build/linux_64_static_make_Debug/tests/unit/
COPY --from=build-image /opt/bb/etc/entrypoint.d/99-mybinary.sh /opt/bb/etc/entrypoint.d/99-mybinary.sh

Expectation from first stage is to build the .tsk files, using the make docker commands which is a wrapper on top of standard cmake commands.第一阶段的期望是使用make docker docker 命令构建 .tsk 文件,该命令是标准 cmake 命令之上的包装器。

I've added the RUN commands in between, to see if the .tsk files have been created.我在两者之间添加了 RUN 命令,以查看是否已创建 .tsk 文件。

#12 [build-image 5/7] RUN pwd
#12 sha256:4f0ad0e7daee557776d6c7dfa2faf48dead48ae75ff699a0898879f85255dd30
#12 0.534 /workarea
#12 DONE 0.7s

#13 [build-image 6/7] RUN ls -l cmake-build/linux_64_static_make_Debug/src/
#13 sha256:7989faeb2d337c955e167e5807eb6c6a980e98ab210bbb428b180fc2838686f0
#13 0.617 total 378068
.....
#13 0.617 -rwxr-xr-x 1 root root 290465864 Oct 15 12:04 mybinary.tsk
#13 DONE 0.7s

And the timestamp is the correct one.时间戳是正确的。 Nothing complaints when the COPY gets run. COPY运行时没有任何抱怨。

Then I run然后我跑

docke-compose run my-test

and run the same ls -l there is nothing in there.并运行相同的ls -l there is nothing in there. So, even though the COPY command was ran, I can't see the files.因此,即使运行了 COPY 命令,我也看不到文件。

My `docker-compose.yaml' is :我的“docker-compose.yaml”是:

my-test:
    build:
      context: .
      dockerfile: test.Dockerfile
    volumes:
      - .:/workarea
    environment:
      - INTEGRATION_TESTS=1

Any idea what I am missing?知道我缺少什么吗? I think there is something going wrong with the volumes.我认为卷有问题。

Any idea what I am missing?知道我缺少什么吗? I think there is something going wrong with the volumes.我认为卷有问题。

Exactly.确切地。 If you delete that bind mount , I mean - .:/workarea , you will surely make it work.如果您删除该bind mount ,我的意思是- .:/workarea ,您肯定会使其工作。

The mybinary.tsk already in the container's folder /workarea , but you mount current working directory . mybinary.tsk已经在容器的文件夹/workarea ,但是您挂载了当前工作目录. on host to workarea of container.在主机上到容器的workarea Then, the contents in host will override the contents in container.然后,主机中的内容将覆盖容器中的内容。

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 如何在保留符号链接的同时在多阶段Docker构建阶段之间复制库文件? - How to COPY library files between stages of a multi-stage Docker build while preserving symlinks? 如何从我的第一个/原始 MainWindow 打开第二个 QMainWindow? - How to open a second QMainWindow from my first/original MainWindow? 迁移CMake可实现多阶段Docker构建 - migrating CMake results in multi-stage Docker build Docker Centos,无法执行二进制文件 - Docker Centos, Cannot Execute Binary File 程序第一次完美运行但是从二进制文件中读取类时第二次想知道seg错误? - Program runs perfectly the first time but wondering seg faults the second time when reading from a class from binary file? 这会复制我的二进制文件中的所有数据吗? - Is this going to copy all the data in my binary files? 通过 Winsock 发送二进制文件不会复制前 4 个字符 - Sending binary file via Winsock doesn't copy first 4 characters 将内容从第一个文件(“选区”)移动到第二个文件(“临时”)并在之后重命名时,我的文件被删除 - My files get deleted when moving content from the first file (“constituencies”) to the second (“temp”) and renaming it after Docker:构建后在容器内运行二进制文件 - 权限被拒绝 - Docker: run binary inside container after build - permission denied 从struct到std :: vector的二进制复制数据 - binary copy data from struct to std::vector
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM