Trying to pass a variable from a RUN
command to a CMD
in a docker image. The v
variable is passed from value
and contains a number, but it does not output when after the container is run. It is declared as as environmental variable and passed to the CMD
. Thank you. :).
RUN apk add -- \
&& cd directory \
&& value=$(....)
ARG value
ENV value=$value
CMD [ "sh", "-c", "echo some text $value" ]
To run:
docker run <image>
current
some text
desired
some text 10
ARG
to store thevalue
on build and then pass that to theENV
for so the$value
is available on run time, butvalue
doesn't expand. I updated theCMD
as well. When I start the container with-it
, I can run thevalue
command andecho
is contents. Thank you :). – justaguy Jan 7 at 13:59