How to change the default docker registry from docker.io to my private registry? How to change the default docker registry from docker.io to my private registry? docker docker

How to change the default docker registry from docker.io to my private registry?


UPDATE: Following your comment, it is not currently possible to change the default registry, see this issue for more info.

You should be able to do this, substituting the host and port to your own:

docker pull localhost:5000/registry-demo

If the server is remote/has auth you may need to log into the server with:

docker login https://<YOUR-DOMAIN>:8080

Then running:

docker pull <YOUR-DOMAIN>:8080/test-image


It turns out this is actually possible, but not using the genuine Docker CE or EE version.

You can either use Red Hat's fork of docker with the '--add-registry' flag or you can build docker from source yourself with registry/config.go modified to use your own hard-coded default registry namespace/index.


There is the use case of a mirror of Docker Hub (such as Artifactory or a custom one), which I haven't seen mentioned here. This is one of the most valid cases where changing the default registry is needed.

Luckily, Docker (at least version 19.03.3) allows you to set a mirror (tested in Docker CE). I don't know if this will work with additional images pushed to that mirror that aren't on Docker Hub, but I do know it will use the mirror instead. Docker documentation: https://docs.docker.com/registry/recipes/mirror/#configure-the-docker-daemon.

Essentially, you need to add "registry-mirrors": [] to the /etc/docker/daemon.json configuration file. So if you have a mirror hosted at https://my-docker-repo.my.company.com, your /etc/docker/daemon.json should contain:

{  "registry-mirrors": ["https://my-docker-repo-mirror.my.company.com"]}

Afterwards, restart the Docker daemon. Now if you do a docker pull postgres:12, Docker should fetch the image from the mirror instead of directly from Docker Hub. This is much better than prepending all images with my-docker-repo.my.company.com