How to view published container images in the Google container registry using gcloud or another CLI

Is there a gcloud or another command line interface (CLI) for accessing a list of published container images in the Google private container registry? (This is the container registry in the Google Cloud Platform project)

gcloud container doesn't seem to help:

 $ gcloud container Usage: gcloud container [optional flags] <group | command> group may be clusters | operations command may be get-server-config Deploy and manage clusters of machines for running containers. flags: --zone ZONE, -z ZONE The compute zone (eg us-central1-a) for the cluster global flags: Run `gcloud -h` for a description of flags available to all commands. command groups: clusters Deploy and teardown Google Container Engine clusters. operations Get and list operations for Google Container Engine clusters. commands: get-server-config Get Container Engine server config. 

I also don't want to use gcloud docker to display images, because it wants to connect to a specific docker demo that I don’t have. If there is a way to tell gcloud docker connect to a remote demonstrator of a public gcloud docker that can read personal containers inserted into the registry through my project.

+5
source share
5 answers

We just released a new team to display images in your repository! You can try:

 gcloud alpha container images list --repository=gcr.io/$MYREPOSITORY 

If you want to see specific tags for an image that you can use:

 gcloud alpha container images list-tags gcr.io/$MYREPOSITORY/$MYIMAGE 
+10
source

The answer given by Robert Bailey is good for certain tasks, but what you specifically want to do may be missing. However, your comments in response to his answer are not so much the flaws of his answer as your understanding of what teams that β€œfail” really mean.

Regarding your second comment,

Using docker, I get the following error (for the reasons indicated above; I also edited the question): Cannot connect to the Docker daemon. Is the docker daemon running on this host? Cannot connect to the Docker daemon. Is the docker daemon running on this host?

This is the result of a docker demo. Check if it works through ps aux | grep docker ps aux | grep docker . You can refer to the Docker documentation to determine how to properly install and run it.

Regarding your first comment,

Using curl, I get: {"errors":[{"code":"DENIED","message":"Failed to read tags for repository '<my_project>/<my_image>'"}]} . I must authenticate in some way access to images in a private registry. I do not want to use docker, because this means that I must have a docker daemon available. I just want to see if the image of the container with the specific version is in the Container Registry. So I need the API in the Container Registry in the Google Developer Console.

You would not be able to curl image if it was not publicly available, as mentioned in Robert's last comment, or if you somehow did not provide some large oauth headers during the curl call.

You should use gcloud docker to try to list images in the registry, as for other docker registries. The gcloud container team group is incorrect for your desired task. You can see below the output of gcloud version 96.0.0 (the last of this comment) for the docker command group:

 $ gcloud docker Usage: docker [OPTIONS] COMMAND [arg...] docker daemon [ --help | ... ] docker [ --help | -v | --version ] A self-sufficient runtime for containers. Options: --config=~/.docker Location of client config files -D, --debug=false Enable debug mode --disable-legacy-registry=false Do not contact legacy registries -H, --host=[] Daemon socket(s) to connect to -h, --help=false Print usage -l, --log-level=info Set the logging level --tls=false Use TLS; implied by --tlsverify --tlscacert=~/.docker/ca.pem Trust certs signed only by this CA --tlscert=~/.docker/cert.pem Path to TLS certificate file --tlskey=~/.docker/key.pem Path to TLS key file --tlsverify=false Use TLS and verify the remote -v, --version=false Print version information and quit Commands: attach Attach to a running container build Build an image from a Dockerfile commit Create a new image from a container changes cp Copy files/folders between a container and the local filesystem create Create a new container diff Inspect changes on a container filesystem events Get real time events from the server exec Run a command in a running container export Export a container filesystem as a tar archive history Show the history of an image images List images import Import the contents from a tarball to create a filesystem image info Display system-wide information inspect Return low-level information on a container or image kill Kill a running container load Load an image from a tar archive or STDIN login Register or log in to a Docker registry logout Log out from a Docker registry logs Fetch the logs of a container network Manage Docker networks pause Pause all processes within a container port List port mappings or a specific mapping for the CONTAINER ps List containers pull Pull an image or a repository from a registry push Push an image or a repository to a registry rename Rename a container restart Restart a container rm Remove one or more containers rmi Remove one or more images run Run a command in a new container save Save an image(s) to a tar archive search Search the Docker Hub for images start Start one or more stopped containers stats Display a live stream of container(s) resource usage statistics stop Stop a running container tag Tag an image into a repository top Display the running processes of a container unpause Unpause all processes within a container version Show the Docker version information volume Manage Docker volumes wait Block until a container stops, then print its exit code Run 'docker COMMAND --help' for more information on a command. 

You should use gcloud docker search gcr.io/project-id to check which images are in the repository. gcloud has your credentials, so it can talk to the private registry if you are authenticated as the appropriate user in the project.


Finally, as an additional resource: Cloud Platform Docs contains an entire article on working with the Google Container Registry .

+3
source

If you know the project that hosts the images (e.g. google-containers ), you can display the images using

 gcloud docker search gcr.io/google_containers 

For a single image (e.g. pause image in google-containers project) you can check versions with

 curl https://gcr.io/v2/google-containers/pause/tags/list 
+1
source

My best solution so far without having a local docker and without the ability to connect to a remote docker (this still requires at least a local docker client, but not a local daemon) is SSH into the container cluster instance that launches docker , and performed my search and got the result in my original script:

 gcloud compute ssh <container_cluster_instance> -C "sudo gcloud docker search ..." 

Of course, to avoid all the detailed results (for example, SSH / Terminal welcome messages), I use a few arguments to silence the execution a bit:

 gcloud compute ssh --ssh-flag="-q" "$INSTANCE_NAME" -o LogLevel=quiet -C "sudo gcloud docker search ..." 
+1
source

I just found a much simpler way to check for specific images. After gcloud authentication gcloud use it to create access tokens to read from your private registry:

 curl -u "oauth2accesstoken:$(gcloud auth print-access-token)" https://gcr.io/v2/<projectName>/<imageName>/tags/list 
0
source

Source: https://habr.com/ru/post/1242522/


All Articles