Windows container build arguments

Hey, I’m trying to build this dockerfile:

with this command: docker build --build-arg stuff=somestuff .

But it seems like the argument in the file is not working at all. It won’t echo the string even if I don’t override it in the build command.
I’m running Windows 10 with version 1.13.1 of Docker for windows and I’ve got it configured for windows containers.
Can anybody here see something wrong with the file or command or can reproduce this?

You have to use:

RUN echo %stuff%

Since you changed the Shell to Powershell, You need to use [Environment]::GetEnvironmentVariable(‘stuff’) to access it. Something like this, will work:

RUN $my_var=echo [Environment]::GetEnvironmentVariable('stuff'); echo $my_var;

If you don’t change the Shell and stay on CMD shell (the default), then you access it with %stuff%

1 Like

OMG! I spent 2 hours trying to figure this out…

I was trying to do:

RUN git config --global http.proxy $HTTP_PROXY && \
    git config --global http.sslVerify false

and build with:

docker image build --build-arg HTTP_PROXY=$env:HTTP_PROXY --tag=...

I am basing on nanoserver-1809 and staying with the default shell CMD. The right way to do it is:

RUN git config --global http.proxy %HTTP_PROXY% && \
    git config --global http.sslVerify false