Docker Community Forums

Share and learn in the Docker community.

Windows container build arguments


(Wafflecakes) #1

Hey, I’m trying to build this dockerfile:
http://pastebin.com/vCfnGinX

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?


(Kirkone) #2

You have to use:

RUN echo %stuff%


(Samincl) #3

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%