title: Access Gitlab CI variable during Docker build
body: <p>I want to use API tokens stored as Gitlab secret variables in my docker file to build a windows container.</p>
  
  <p>The needed API token is stored as secret variable in Gitlab. A build job will be executed and passes this token to my docker build command as build argument:</p>
  
  <pre><code>docker build $MemoryParameters $Env:DOCKER_BUILD_ADDITIONAL_ARGUMENTS
      --pull `
      --build-arg CI_TOKEN=$Env:CI_TOKEN `
      -t $TempImageName .
  </code></pre>
  
  <p>Accessing the variable with <code>$Env:CI_TOKEN</code> works as intended.</p>
  
  <p>Trying to reference it in my docker file:</p>
  
  <pre><code>ARG CI_TOKEN
  
  FROM mcr.microsoft.com/dotnet/framework/runtime:4.8
  
  //Some RUN commands
  
  RUN  echo "token= %CI_TOKEN%"
  </code></pre>
  
  <p><code>%CI_TOKEN%</code> in the docker file will not be replaced by it's actual value stored in Gitlab. </p>
  
  <p>How should it be referenced?</p>
  
  <p>I'm not quite sure about the interpreter of the base image, but I assume cmd rather than powershell.</p>