Docker private registry with mirror

ID : 274545

viewed : 31

Tags : dockerdocker-registrydocker





Top 5 Answer for Docker private registry with mirror

vote vote

95

You cannot just force all docker push commands to push to your private registry. One reason is that you can have any number of those registers. You have to first tell docker where to push by tagging the image (see lower).

Here is how you can setup docker hosts to work with a running private registry and local mirror.

Client set-up

Lets assume that you are running both mirror and private registry on (resolvable) host called dockerstore. Mirror on port 5555, registry on 5000.

Then on client machine(s) you should pass extra options to docker daemon startup. In your case:

  1. Add --registry-mirror=http://dockerstore:5555 to tell daemon to prefer using local mirror rather then dockerhub. source
  2. Add --insecure-registry dockerstore:5000 to access the private registry without further configuration. See this answer
  3. Restart docker daemon

Using the mirror

When you pull any image the first source will be the local mirror. You can confirm by running a docker pull, e.g.

docker pull debian 

In the output there will be message that image is being pulled from your mirror - dockerstore:5000

Using local registry

In order to push to private registry first you have to tag the image to be pushed with full name of the registry. Make sure that you have a dot or colon in the first part of the tag, to tell docker that image should be pushed to private registry.

Docker looks for either a “.” (domain separator) or “:” (port separator) to learn that the first part of the repository name is a location and not a user name.

Example:

Tag 30d39e59ffe2 image as dockerstore:5000/myapp:stable

docker tag 30d39e59ffe2 dockerstore:5000/myapp:stable 

Push it to private registry

docker push dockerstore:5000/myapp:stable 

Then you can pull as well

docker pull dockerstore:5000/myapp:stable 
vote vote

84

Just to be clear, docker documentation confirms that:

It’s currently not possible to mirror another private registry. Only the central Hub can be mirrored.

vote vote

80

If not present, create the file:

sudo nano /etc/docker/daemon.json 

Then paste the following:

{   "registry-mirrors": [     "https://hub-mirror.c.163.com",     "https://mirror.baidubce.com"   ] } 

Then retart Docker daemon

$ sudo systemctl restart docker 

[Source]

vote vote

61

Repository names are intended to be global, that is the repository redis always refers to the official Redis image from the Docker Hub. If you want to use a private registry, you prefix the repository name with the name of the registry e.g. localhost.localdomain:5000/myimage:mytag.

So when you pull or push, it will automatically go to the relevant registry. The mirror should be easy to set up, you just pass the URL to the daemon with the --registry-mirror= argument.

This isn't perfect for enterprise users, hence this (closed) Docker issue.

vote vote

56

Top 3 video Explaining Docker private registry with mirror







Related QUESTION?