title: Consume secret inside dockerfile
body: <p>Is it possible to <strong>access machine environments inside dockerfile</strong>? I was thinking passing the SECRET as build ARG, like so:</p>
  <p>docker-compose:</p>
  <pre class="lang-yaml prettyprint-override"><code>version: '3.5'
  services:
    service:
      ...
      build:
        ...
        args:
          SECRET: ${SECRET}
      ...
  </code></pre>
  <p>dockerfile:</p>
  <pre><code>FROM image
  ARG SECRET
  RUN script-${SECRET}
  
  </code></pre>
  <p><em>Note:</em> the container is build in kubernetes, I can not pass any arguments to the build command or perform any command at all.</p>
  <p><em>Edit 1:</em> It is okay to pass SECRET as ARG because this is not sensitive data. I'm using SECRETS to access micro service data, and I can only store data using secrets. Think of this as machine environment.</p>
  <p><em>Edit 2:</em> This was not a problem with docker but with the infrastructure that I was working with which does not allow any arguments to be passed to the docker build.</p>