[英]windows docker-compose args not working
I'm trying to use args in a docker compose file. 我正在尝试在docker compose文件中使用args。
The docker-compose file: docker-compose文件:
version: '3'
services:
service1:
image: test
restart: always
build:
context: C:/ProgramData/
dockerfile: Dockerfile
args:
entry: 1
volumes:
- C:/ProgramData/test
The Dockerfile: Dockerfile:
FROM microsoft/dotnet-framework:3.5
ARG entry
WORKDIR C:\\test
ADD ["/bin/x86/Release/","C:/test/"]
ENTRYPOINT ["C:\\test\\file.exe", ${entry}]
I don't know how exactly works the syntax in the docker file. 我不知道docker文件中的语法如何正常工作。 How I have to put the arg in the
ENTRYPOINT
? 我如何将arg放在
ENTRYPOINT
?
You cannot use ARG
in ENTRYPOINT
(at least not directly). 您不能在
ENTRYPOINT
使用ARG
(至少不能直接使用)。 See How to pass ARG value to ENTRYPOINT? 请参阅如何将ARG值传递给ENTRYPOINT? :
:
Both ARG and ENV are not expanded in ENTRYPOINT or CMD.
ARG和ENV都不会在ENTRYPOINT或CMD中扩展。 ( https://docs.docker.com/engine/reference/builder/#environment-replacement ) However, because ENVs are passed in as part of the environment, they are available at run time, so the shell can expand them.
( https://docs.docker.com/engine/reference/builder/#environment-replacement )但是,由于ENV是作为环境的一部分传入的,因此它们在运行时可用,因此Shell可以对其进行扩展。 (This means you can't use the array form of ENTRYPOINT or CMD.)
(这意味着您不能使用ENTRYPOINT或CMD的数组形式。)
I solved this issue by changing the Dockerfile as follows: 我通过更改Dockerfile来解决此问题,如下所示:
FROM microsoft/dotnet-framework:3.5
ARG ENTRY
ENV my_env=$ENTRY
#RUN echo %ENTRY%
#RUN echo %my_env%
WORKDIR C:\\test
ADD ["/bin/x86/Release/","C:/test/"]
ENTRYPOINT C:/test/file.exe %my_env%
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.