title: Unset environment variable in compose
body: <p>I have a Dockerfile that requires two environment variables:</p>
  
  <pre><code>ARG AWS_ACCESS_KEY_ID
  ARG AWS_SECRET_ACCESS_KEY
  </code></pre>
  
  <p>I'm passing them from the host through my compose file using:</p>
  
  <pre><code>build:
    # ...
    args:
      - AWS_ACCESS_KEY_ID
      - AWS_SECRET_ACCESS_KEY
  </code></pre>
  
  <p>My problem is that in some flows there is an IAM role set (and no env vars) and I don't want to use the environment variables. But even when they don't exist on the host they seem to be set to empty strings during the build process.</p>
  
  <p>I've tried this:</p>
  
  <pre><code>run if [ -z "$AWS_ACCESS_KEY_ID" ]; then unset AWS_ACCESS_KEY_ID; fi
  run if [ -z "$AWS_SECRET_ACCESS_KEY" ]; then unset AWS_SECRET_ACCESS_KEY; fi
  
  run env # see if set
  </code></pre>
  
  <p>But it doesn't work (the variables are still set even if not set in host env).</p>
  
  <p>I'd welcome another solution on mixing env vars and IAM roles when building dockers.</p>