<p>Yes, it is possible. The entire subject is discussed in <a href="https://docs.docker.com/registry/recipes/mirror/#run-a-registry-as-a-pull-through-cache" rel="nofollow noreferrer">Registry as a pull through cache</a>, from where the below quotes are taken. </p>

<p>Basically you need to configure the cache as a proxy for Docker Hub:</p>

<blockquote>
  <p><strong>Configure the cache</strong></p>
  
  <p>To configure a Registry to run as a pull through cache, the addition
  of a <code>proxy</code> section is required to the config file.</p>
  
  <p>In order to access private images on the Docker Hub, a username and
  password can be supplied.</p>

<pre><code>proxy:
  remoteurl: https://registry-1.docker.io
  username: [username]
  password: [password]
</code></pre>
</blockquote>

<p>Of course, you also need to configure your docker daemon to use your local cache (but I presume that may be already done from the context of the question):</p>

<blockquote>
  <p><strong>Configure the Docker daemon</strong></p>
  
  <p>Either pass the <code>--registry-mirror</code> option when starting <code>dockerd</code>
  manually, or edit <code>/etc/docker/daemon.json</code> and add the
  <code>registry-mirrors</code> key and value, to make the change persistent.</p>

<pre><code>{
  "registry-mirrors": ["https://&lt;my-docker-mirror-host&gt;"]
}
</code></pre>
</blockquote>

CC BY-SA 3.0
2017-11-09T01:12:37.410Z
ok this does not solve the problem, as apparently you have to choose between configuring the registry as a mirroring cache *or* as a local registry. When it is configured as a mirroring cache, pushing local images is disabled
lurscher
CC BY-SA 3.0
2017-11-09T03:00:23.457Z
Right - it wouldn't be a *mirroring* cache if it would contain images not found in what it's mirroring... But your question update addresses that, I think.
Dan Cornilescu
CC BY-SA 3.0
2017-11-08T18:05:37.853Z
2017-11-08T18:05:37.853Z
Dan Cornilescu
<p>I have a docker registry image running on a local network with the command</p>

<pre><code>docker run -d -p 5000:5000 --restart=unless-stopped --name registry -v /mnt/part_sdb/registry:/var/lib/registry registry:2
</code></pre>

<p>but enabling the caching of images stored in Docker Hub requires one to pull the image, and push it in the local registry</p>

<p>Is there a way to configure the docker registry to do automatic pull-through if the image requested is not available locally <strong>while preserving the ability to push local images</strong>?</p>

<p>from <a href="https://medium.com/@andrenit/docker-and-artifactory-as-a-registry-mirror-1365891b39c5" rel="nofollow noreferrer">this article</a>:</p>

<blockquote>
  <p>The catch is that you will probably run the public Registry as a
  mirror <em>or</em> as a regular registry, so you will probably end up running
  two containers — one as a mirror, another as your local Registry (not
  a big deal). In artifactory you can set up as many registries as you
  want (local or remote), each with its own URL. Or you can “mix” them
  on a single URL with a virtual registry (if you think it is a good
  idea).</p>
</blockquote>

<docker><registry>
Private docker registry that attempts a pull-through on images not found locally
lurscher
# Private docker registry that attempts a pull-through on images not found locally

(Asked by: username_0 on 2017-11-08)

I have a docker registry image running on a local network with the command
docker run -d -p 5000:5000 --restart=unless-stopped --name registry -v /mnt/part_sdb/registry:/var/lib/registry registry:2

but enabling the caching of images stored in Docker Hub requires one to pull the image, and push it in the local registry
Is there a way to configure the docker registry to do automatic pull-through if the image requested is not available locally while preserving the ability to push local images?
from this article:

The catch is that you will probably run the public Registry as a
  mirror or as a regular registry, so you will probably end up running
  two containers — one as a mirror, another as your local Registry (not
  a big deal). In artifactory you can set up as many registries as you
  want (local or remote), each with its own URL. Or you can “mix” them
  on a single URL with a virtual registry (if you think it is a good
  idea).

**Tags:** docker, registry


---

## 1 answers

### Answer by username_1 on 2017-11-08. Score: 1

Yes, it is possible. The entire subject is discussed in Registry as a pull through cache, from where the below quotes are taken. 
Basically you need to configure the cache as a proxy for Docker Hub:

Configure the cache
To configure a Registry to run as a pull through cache, the addition
  of a proxy section is required to the config file.
In order to access private images on the Docker Hub, a username and
  password can be supplied.
proxy:
  remoteurl: https://registry-1.docker.io
  username: [username]
  password: [password]


Of course, you also need to configure your docker daemon to use your local cache (but I presume that may be already done from the context of the question):

Configure the Docker daemon
Either pass the --registry-mirror option when starting dockerd
  manually, or edit /etc/docker/daemon.json and add the
  registry-mirrors key and value, to make the change persistent.
{
  "registry-mirrors": ["https://"]
}

> **Comments:**
> **username_0**: ok this does not solve the problem, as apparently you have to choose between configuring the registry as a mirroring cache *or* as a local registry. When it is configured as a mirroring cache, pushing local images is disabled  
> **username_1**: Right - it wouldn't be a *mirroring* cache if it would contain images not found in what it's mirroring... But your question update addresses that, I think.  

---

