Docker: get list of all the registries configured on a host
Asked Answered
D

1

12

Can docker be connected to more than one registry at a time and how to figure out which registries it is currently connected too?

$ docker help | fgrep registr
login       Log in to a Docker registry
logout      Log out from a Docker registry
pull        Pull an image or a repository from a registry
push        Push an image or a repository to a registry

As you can see, there is no option to list the registries. I did find a way by running:

$ docker system info | fgrep -i registr
 Registry: https://index.docker.io/v1/

So... one regsitry at a time only? It is not like apt where one can point to more than one source? Anybody can point me to some good documentation about docker and registries?

Oddly, I search the web to no vail.

Diphase answered 6/2, 2022 at 23:50 Comment(0)
K
16

Aside from docker login, Docker isn't "connected to a registry" per se. Registry names are part of the image name, and Docker will connect to a registry server if it needs to pull an image.

As a specific example, the official Docker image for Elasticsearch is on a non-default registry run by Elastic. The example in that documentation is

docker pull docker.elastic.co/elasticsearch/elasticsearch:7.17.0
#           ^^^^^^^^^^^^^^^^^
#           registry host name

You don't need to otherwise configure your system to connect to that registry, download an index, or anything else. In fact, you don't even need this docker pull command; if you directly docker run the image, Docker will download it if it doesn't have a copy locally.

The default registry is Docker Hub, docker.io, and this cannot be changed.

There are several alternate registries out there. The various public-cloud providers each have their own, and there are also several free-standing image registries. Each has its own instructions on how to set it up. You always need to include the registry name as part of the image name. The Google Container Registry has a simple name syntax, for example, so if you use GCR then you can

# build an image locally, labeled to be stored in GCR
# (this step does not contact or use GCR at all)
docker build gcr.io/my-name/my-image:tag

# authenticate to the registry
# (normally GCR has a Google-specific login sequence)
docker login https://gcr.io

# push the image
docker push gcr.io/my-name/my-image:tag

# run the image, pulling it if not present
docker run ... gcr.io/my-name/my-image:tag
Kittenish answered 7/2, 2022 at 1:46 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.