title: SAM build in container with environment variables
body: <p>Is there a way to pass environment variables to the container doing the build in:</p>
  <pre><code>sam build --use-container
  </code></pre>
  <p>In the sam build <a href="https://docs.aws.amazon.com/serverless-application-model/latest/developerguide/sam-cli-command-reference-sam-build.html" rel="nofollow noreferrer">documentation</a>, in parameters related to Docker, there is only <code>--docker-network</code> and <code>--skip-pull-image</code></p>
  <h3>Use case:</h3>
  <p>I am using private PyPI repository, and I need to pass credentials as environment variables.</p>
  <h3>Workaround:</h3>
  <p>A workaround is:</p>
  <ul>
  <li>Pull the docker image used by sam, e.g. <code>lambci/lambda:build-python3.7</code></li>
  <li>Build a new image with same name &amp; tag</li>
  <li>Run <code>sam build -u</code> with parameter <code>--skip-pull-image</code></li>
  </ul>
  <h3>Update 1:</h3>
  <p>Created a feature request in SAM repo: <a href="https://github.com/aws/aws-sam-cli/issues/2144" rel="nofollow noreferrer">https://github.com/aws/aws-sam-cli/issues/2144</a></p>
  <h3>Update 2:</h3>
  <p>New parameters were released: <code>--container-env-var</code> and <code>--container-env-var-file</code> in <a href="https://github.com/aws/aws-sam-cli/releases/tag/v1.20.0" rel="nofollow noreferrer">v1.20.0</a></p>