Can I use host env variable in source part of COPY command in Dockerfile.
Eg: I have env varianle MY_HOME = /abc/def
Can I use following in Dockerfile?
COPY ${MY_HOME}/xyz.conf /ams/config/xyz.conf
You can use environment variables like RUN echo $HOME > /home.txt. But be aware of the fact, that in COPY commands you can only use files that are in the 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.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With