Reputation:
In a Windows docker container I'm trying to set an environment variable based on a build argument.
I have tried this:
docker build --build-arg MYVAR="test" .
In the Dockerfile I have:
#escape=`
ARG MYVAR
ENV MYENVVAR {`"endpointCredentials`": [{`"password`": `"$Env:MYVAR`"}]}
But when I run Get-Item $Env:MYVAR
I get:
{"endpointCredentials": [{"password":":MYVAR"}]}
What I want is
{"endpointCredentials": [{"password":"test"}]}
Upvotes: 1
Views: 1957
Reputation: 41545
The --build-arg
is to pass arguments to the Dockerfile, so you need to configure the MYVAR
as an argument in the Dockerfile:
ARG MYVAR
ENV MYENVAR {`"endpointCredntials`": [{`"password`": "$MYVAR"}]}
Upvotes: 2