LinuxCommandLibrary

gcrane-ls

List container image tags and repositories

TLDR

List the tags

$ gcrane ls [repository]
copy

Format response from the registry as JSON
$ gcrane ls [repository] --json
copy

Whether to recurse through repositories
$ gcrane ls [repository] [[-r|--recursive]]
copy

Display help
$ gcrane ls [[-h|--help]]
copy

SYNOPSIS

gcrane ls [options] <registry/path>
The <registry/path> specifies the registry endpoint or a specific repository within it (e.g., gcr.io/my-project or us-east1-docker.pkg.dev/my-project/my-repo).

PARAMETERS

--json
    Output the list of images and tags in JSON format.

--recursive, -r
    List images and repositories recursively within the specified registry path.

--tags-only, -s
    When used, this flag limits the output to only image tags. It implies and behaves like --recursive, listing all tags found under the specified path.

DESCRIPTION

gcrane-ls is a subcommand of the gcrane tool, designed for efficient interaction with container registries, particularly Google Container Registry (GCR) and Artifact Registry. Its primary function is to list container images and their tags within a specified repository or across an entire registry path. It provides a more streamlined way to browse registry contents compared to gcloud or docker commands for similar purposes, offering flexible output formats and filtering capabilities. It's often used for inventorying images, checking image existence, or understanding the structure of a registry for automation and scripting purposes.

CAVEATS

Authentication: Requires proper authentication (e.g., gcloud auth configure-docker or service account credentials) to access private registries.

Permissions: User or service account needs appropriate permissions (e.g., storage.objects.list for GCR) to list images.

Rate Limiting: Excessive requests might hit registry rate limits, leading to temporary service disruption.

Large Registries: Listing recursively on very large registries can take considerable time and consume more resources.

AUTHENTICATION

Before using gcrane-ls, ensure you are authenticated to your container registry. For Google Container Registry or Artifact Registry, this typically involves running gcloud auth configure-docker or setting up appropriate service account credentials. Missing authentication will result in permission denied errors.

USAGE EXAMPLES

gcrane ls gcr.io/my-project
Lists all top-level image repositories within 'my-project'.

gcrane ls -r gcr.io/my-project/my-app
Recursively lists all image tags under the 'my-app' repository.

gcrane ls --json -r gcr.io/my-project | jq .
Lists all images and tags recursively for 'my-project' in JSON format and pipes it to jq for pretty-printing.

HISTORY

gcrane is a tool developed by Google. It emerged as a more performant and programmatic alternative to gcloud commands for interacting with Google's container registries (GCR and Artifact Registry). gcrane-ls specifically addresses the need for quick and flexible listing of registry contents, providing features like recursive listing and JSON output that are highly beneficial for scripting and automation. It's often used in CI/CD pipelines or for inventory management of container assets.

SEE ALSO

gcrane(1), crane(1), docker(1), skopeo(1), gcloud(1)

Copied to clipboard