<p>According to <a href="https://docs.docker.com/registry/configuration/" rel="nofollow noreferrer">Docker docs</a>, you can configure a the docker registry image by either:</p>
<ol>
<li>building a yaml file &amp; mounting it.</li>
<li>Pass Environment Variables.</li>
</ol>
<p>And the 2. approach says <a href="https://docs.docker.com/registry/configuration/" rel="nofollow noreferrer">in the docs</a>:</p>
<blockquote>
<p>To override a configuration option, create an environment variable named REGISTRY_variable where variable is the name of the configuration option and the _ (underscore) represents indention levels. For example, you can configure the rootdirectory of the filesystem storage backend:</p>
<pre><code>storage:
  filesystem:
    rootdirectory: /var/lib/registry
</code></pre>
<p>To override this value, set an environment variable like this:</p>
<pre><code>REGISTRY_STORAGE_FILESYSTEM_ROOTDIRECTORY=/somewhere
</code></pre>
<p>This variable overrides the /var/lib/registry value to the /somewhere directory.</p>
</blockquote>
<p>Which works perfectly although there's one case where I cannot make it work, and that is Middleware config.</p>
<p>I want to pass by ENV vars this piece of setup</p>
<pre><code>middleware:
  storage:
    - name: cloudfront
      options:
        baseurl: https://my.cloudfronted.domain.com/
        privatekey: /path/to/pem
        keypairid: cloudfrontkeypairid
        awsregion: us-east-1, use-east-2
</code></pre>
<p>I've tried passing the following env var names:</p>
<pre><code>- REGISTRY_MIDDLEWARE_STORAGE_CLOUDFRONT_BASEURL
- REGISTRY_MIDDLEWARE_STORAGE_0_OPTIONS_BASEURL
</code></pre>
<p>but all of them seemed to be ignored, I've even tried to miswrite the config (as this will trigger a validation error and I'll be able to see it in the output), but no success.</p>
<p>I tried it with this:</p>
<pre><code># file.env
REGISTRY_LOG_LEVEL=&quot;debug&quot;
REGISTRY_HTTP_ADDR=&quot;:5000&quot;
REGISTRY_HTTP_SECRET=&quot;lol&quot;

REGISTRY_STORAGE_S3_ENCRYPT=true
REGISTRY_STORAGE_S3_ROOTDIRECTORY=/REG
REGISTRY_STORAGE_S3_BUCKET=&quot;development-bucket-test&quot;
REGISTRY_STORAGE_S3_ACCESSKEY=&quot;AAAAAAAA&quot;
REGISTRY_STORAGE_S3_SECRETKEY=&quot;BBBBBBB&quot;
REGISTRY_STORAGE_S3_REGION=&quot;XX-TTT-X&quot;

REGISTRY_MIDDLEWARE_STORAGE_CLOUDFRONT_BASEURL=&quot;tp:/examplezzz.com&quot;
REGISTRY_MIDDLEWARE_STORAGE_CLOUDFRONT_BASEUL=&quot;tp:/examplezzz.com&quot;

REGISTRY_MIDDLEWARE_STORAGE_0_NAME=cloudfront
REGISTRY_MIDDLEWARE_STORAGE_0_OPTIONS_BASEUL=&quot;tp:/examplezzz.com&quot;
REGISTRY_MIDDLEWARE_STORAGE_0_OPTIONS__AWSRGION=&quot;tp:/examplezzz.com&quot;
</code></pre>
<pre class="lang-sh prettyprint-override"><code># run the registry with
docker run --rm -it -p 5000:5000 --env-file file.env registry:2.7.1 sh -c 'echo &quot;version: 0.1&quot; &gt; /a.conf; registry serve /a.conf'
</code></pre>
<p>P.S.: The <code>/a.conf</code> is there to force an empty configuration</p>
<p>Am I missing something or is this setting only possible with config files?</p>

josegomezr
<p>I went ahead and tinker with the sourcecode of the docker distribution by myself and made it accept the configs by passing:</p>
<pre><code>REGISTRY_MIDDLEWARE_STORAGE=&quot;[{name: cloudfront, options: {baseurl: 'someurl', privatekey: 'somefile', keypairid: 'somestring'}}]&quot;
</code></pre>
