Why is the tag closely related to the registry host name?

I have read many lessons on how to configure and use my own private docker registry.

One thing that alerted me was the fact that the tag by which I put the image looks closely related to the registry host name.

docker tag <imageid> registry.mycompany.com:5000/myrepo:tag docker push registry.mycompany.com:5000/myrepo:tag 

It seems really controversial. What happens if the registry needs to switch to a different host name? Or if I use different host names, regardless of whether I use the server inside / outside?

What seems more intuitive to me is to specify the registry when pressed / pulled:

 docker tag <imageid> myrepo:tag docker push myrepo:tag --registry=registry.mycompany.com docker pull myrepo:tag --registry=registry.mycompnay.com 

What is the reason for this? What key bit of information do I miss?

+5
source share
2 answers

The URL / registry name is essentially a "namespace" for the image. If you do not specify a registry, it is assumed that the image belongs to the Docker Hub. Essentially, this means that Docker Inc manages the global namespace.

If this were not done in this way, you could have two completely different β€œpushed” images on separate hosts with the same name, which should not be avoided by Docker.

Moving the registry server is a serious problem, so I suggest you try using a domain name rather than IP for your registry.

+3
source

the tag with which I am placing the image seems to be closely related to the registry host name.

Not really: the registry is used in the URL of the registry server used to push / pull the image.

Even if you change the server, the name of the image that you will use for push / pull will still be the same, only the URL will change (as described in library/registry and docker/docker-registry ).

0
source

All Articles