Docker show current registry
Asked Answered
M

3

40

In docker, how can one display the current registry info you are currently logged in? I installed docker, if I now do docker push, where does it send my images?

I spend over 30min searching this info from Google and docker docs, and couldn't find it, so I think it deserves its own question.

Malfeasance answered 27/9, 2016 at 14:25 Comment(1)
Ikr, i'm searching google about personal registry for only a pull, and still blocked for hours.Brainwork
C
46

There's no concept of a "current" registry - full image tags always contain the registry address, but if no registry is specified then the Docker Hub is used as the default.

So docker push user/app pushes to Docker Hub. If you want to push it to a local registry you need to explicitly tag it with the registry address:

docker tag user/app localhost:5000/user/app
docker push localhost:5000/user/app

If your local registry is secured, you need to run docker login localhost:5000 but that does not change the default registry. If you push or pull images without a registry address in the tag, Docker will always use the Hub.

This issue explains the rationale.

Coridon answered 27/9, 2016 at 14:32 Comment(7)
Feels pretty good answer. Can I pull an image the same way? If I want to use private registry (local or external), I need to first login, and then ensure that the image tag contains the private registry address, and then push it?Malfeasance
Yes, exactly. Say you wanted your own Ubuntu base image: docker pull ubuntu gets you the official image from the Hub; docker tag ubuntu localhost:5000/bases/ubuntu tags it for the local registry; docker push localhost:5000/bases/ubuntu pushes it locally. Then you cal docker pull localhost:5000/bases/ubuntu, or use it in Dockerfiles: FROM localhost:5000/bases/ubuntuCoridon
It anwser for the push, but I am wondering how the pull works, is it configured and where?Brainwork
There is no current, but a default registry. This is set to a different URL on Redhat RHEL system.Frozen
But how does docker tell a registry address from a docker hub user name? For example, if I do docker push east-us.azurecr.io/my-image:v0.1.0, how does it know "east-us.azurecr.io" is not my user name in docker hub? thxGisarme
@Gisarme 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.Towhaired
@Towhaired Which means dots are not allowed in user names?Gisarme
B
7

The way docker images work is not the most obvious but it is easy to explain.

The location where your images will be sent to must be define in the image name. When you commit an image you must name it [registry-IP]:[registry-port]/[imagepath]/[image-name]

If you already have the image created and you want to send it to the local registry you must tagged it including the registry path before you push it:

docker tag [image-name] [registry-IP]:[registry-port]/[image-name]

docker push [registry-IP]:[registry-port]/[image-name]

Burnight answered 27/9, 2016 at 14:39 Comment(0)
F
0

I have also encountered this problem while learning docker.

  • what happens when you don't know the name of your registry where you have to push the images or where do you build your image if you don't remember the name of the registry. Basically, the registry is just the name of your account in your docker hub. Just go to docker desktop and click on the images tab from the left panel. See this image for reference

Then just you can push using this command
docker push <YourRegistryName>/express:v1

Frowsty answered 12/6, 2023 at 9:51 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.