gpt4 book ai didi

docker - 我们可以在Docker文件COPY命令中使用本地env变量吗?

转载 作者:行者123 更新时间:2023-12-02 19:27:07 24 4
gpt4 key购买 nike

我可以在COPYDockerfile命令的源代码部分中使用host env变量吗?
例如:
我有env varibale MY_HOME = /abc/def
我可以在Dockerfile中使用following吗?
COPY ${MY_HOME}/xyz.conf /ams/config/xyz.conf
谢谢

最佳答案

您可以使用RUN echo $HOME > /home.txt之类的环境变量。但请注意,在COPY命令中,您只能使用build context中的文件。

The docker build command builds Docker images from a Dockerfile and a “context”. A build’s context is the set of files located in the specified PATH or URL. The build process can refer to any of the files in the context. For example, your build can use a COPY instruction to reference a file in the context.

关于docker - 我们可以在Docker文件COPY命令中使用本地env变量吗?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/55255199/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com