[英]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.