Skip to content

Latest commit

 

History

History
229 lines (179 loc) · 14.8 KB

File metadata and controls

229 lines (179 loc) · 14.8 KB
copyright
years
2017, 2026
lastupdated 2026-05-13
keywords commands, format commands, filter command output, private registry, registry, commands, formatting output, filtering output, output, Go template format options, data types, cli, config, healthcheck, rootfs, go template, cli output
subcollection Registry

{{site.data.keyword.attribute-definition-list}}

Formatting and filtering the {{site.data.keyword.registryshort_notm}} CLI output

{: #registry_cli_list}

You can format and filter the {{site.data.keyword.registrylong}} command-line interface (CLI) output for supported {{site.data.keyword.registrylong_notm}} commands. {: shortdesc}

By default, the CLI output is displayed in a human-readable format. However, this view might limit your ability to use the output, particularly if the command is run programmatically. For example, in the ibmcloud cr image-list CLI output you might want to sort the Size field in numerical order, but the command returns a string description. The container-registry CLI plug-in provides the format option that you can use to apply a Go template{: external} to the CLI output.

You can alter the CLI output by applying the format option in two different ways:

  • Format the data in your CLI output. For example, change the Created field output from UNIX® time to standard time.
  • Filter the data in your CLI output. For example, filter by details of the image to display a specific subset of images by using the Go template{: external} if gt condition.

You can use the format option with the following {{site.data.keyword.registrylong_notm}} commands. Click a command to view a list of available fields and their data types.

Go template options for ibmcloud cr image-digests

{: #registry_cli_list_imagedigests}

Review the following table to find available Go template{: external} options and data types for the ibmcloud cr image-digests command.

Field Type Description
Created Integer (64 bit) This option displays when the image was created, expressed by the number of seconds in UNIX time.
Digest String This option displays the unique identifier for an image.
ManifestType String This option displays the image manifest type.
Repository String This option displays the repository of the image.
SecurityStatus Object This option displays the vulnerability status for the image. You can filter and format the following values: \n - Status string \n - IssueCount int \n - ExemptionCount int \n \n The possible statuses are described in Reviewing a vulnerability report by using the CLI.
Size Integer (64 bit) This option displays the size of the image in bytes.
Tags Array of strings This option displays the tags for the image.
{: caption="Available fields and data types in the {{site.data.keyword.registryshort_notm}} command to list image digests" caption-side="bottom"}
{: #table_registry_cli_list_image_digests}

Example Go format command for ibmcloud cr image-digests

{: #registry_cli_list_imagedigests_go}

To display all untagged images referenced by their digests, run the following ibmcloud cr image-digests command.

ibmcloud cr image-digests --format '{{if not .Tags}}{{.Repository}}@{{.Digest}}{{end}}'

{: pre}

The following message is an example of the output from the command

example-<region>.icr.io/user1/my_first_repo@<digest1>
example-<region>.icr.io/user1/my_first_repo@<digest2>
example-<region>.icr.io/user1/my_first_repo@<digest3>

{: screen}

Go template options for ibmcloud cr image-list

{: #registry_cli_list_imagelist}

Review the following table to find available Go template{: external} options and data types for the ibmcloud cr image-list command.

Field Type Description
Created Integer (64 bit) This option displays when the image was created, expressed by the number of seconds in UNIX time.
Digest String This option displays the unique identifier for an image.
ManifestType String This option displays the image manifest type.
Namespace String This option displays the namespace where the image is stored.
Repository String This option displays the repository of the image.
SecurityStatus Object This option displays the vulnerability status for the image. You can filter and format the following values: \n - Status string \n - IssueCount int \n - ExemptionCount int \n \n The possible statuses are described in Reviewing a vulnerability report by using the CLI.
Size Integer (64 bit) This option displays the size of the image in bytes.
Tag String This option displays the tag for the image.
{: caption="Available fields and data types in the {{site.data.keyword.registryshort_notm}} command to list images" caption-side="bottom"}
{: #table_registry_cli_list_images}

Example Go format command for ibmcloud cr image-list

{: #registry_cli_list_imagelist_go}

To display the repository, tag, and security status of all tagged images that are over 1 MB, run the following ibmcloud cr image-list command.

ibmcloud cr image-list --format "{{ if gt .Size 1000000 }}{{ .Repository }}:{{ .Tag }} {{ .SecurityStatus.Status }}{{end}}"

{: pre}

The following message is an example of the output from the command:

example-<region>.icr.io/user1/my_first_repo:latest No Issues
example-<region>.icr.io/user1/my_second_repo:1 2 Issues
example-<region>.icr.io/user1/my_second_repo:test1 1 Issue
example-<region>.icr.io/user1/my_second_repo_2:test2 7 Issues

{: screen}

If the listing images command times out, see Why is it timing out when I list images? for assistance. {: tip}

Go template options for ibmcloud cr image-inspect

{: #registry_cli_list_imageinspect}

Review the following table to find available Go template{: external} options and data types for the ibmcloud cr image-inspect command.

Field Type Description
Architecture String This option displays the processor architecture that was used to build this image, and that is required to run the image.
Author String This option displays the author of the image.
Comment String This option displays the description of the image.
Config Object This option displays the configuration metadata for the image. For more information, see Config field details.
Container String This option displays the ID of the container that created the image.
ContainerConfig Object This option displays the default configuration for containers that are started from this image. For more information, see Config field details.
Created String This option displays the UNIX timestamp when the image was created.
DockerVersion String This option displays the Docker version that was used to build this image.
ID String This option displays the unique identifier for an image.
Os String This option displays the operating system family that was used to build this image, and that is required to run the image.
OsVersion String This option displays the version of the operating system that was used to build this image.
Parent String This option displays the ID of the parent image that was used to build this image.
RootFS Object This option displays the metadata that describes the root file system for the image. For more information, see RootFS field details.
Size Integer (64 bit) This option displays the size of the image in bytes.
VirtualSize Integer (64 bit) This option displays the sum of the sizes of each layer in the image in bytes.
{: caption="Available fields and data types in the {{site.data.keyword.registryshort_notm}} command to inspect images" caption-side="bottom"}
{: #table_registry_cli_list_image_inspect}

Config field details

{: #registry_cli_list_imageinspect_config}

Field Type Description
ArgsEscaped Boolean [Windows]{: tag-windows} This option displays true if the command is escaped (Windows® specific).
AttachStderr Boolean This option displays true if the standard error stream is attached to the container and false if not.
AttachStdin Boolean This option displays true if the standard input stream is attached to the container and false if not.
AttachStdout Boolean This option displays true if the standard output stream is attached to the container and false if not.
Cmd Array of strings This option describes the commands and arguments that are passed to a container to run when the container is started.
Domainname String This option displays the fully qualified domain name of the container.
Entrypoint Array of strings This option describes the command that is run when the container starts.
Env Array of strings This option displays the list of environment variables in the form of key-value pairs.
ExposedPorts Key-value map This option displays the list of exposed ports in the format [123:,456:].
Healthcheck Object This option describes how to check that the container is working correctly. For more information, see Healthcheck field details.
Hostname String This option displays the hostname of the container.
Image String This option displays the name of the image that was passed by the operator.
Labels Key-value map This option displays the list of labels that were added to the image as key-value pairs.
MacAddress String This option displays the MAC address that is assigned to the container.
NetworkDisabled Boolean This option displays true if the networking is disabled for the container and false if the networking is enabled for the container.
OnBuild Array of strings This option displays the ONBUILD metadata that was defined on the image Dockerfile.
OpenStdin Boolean This option displays true if the standard input stream is open and false if the standard input stream is closed.
Shell Array of strings This option displays the shell-form of RUN, CMD, ENTRYPOINT.
StdinOnce Boolean This option displays true if the standard input stream is closed after the attached client disconnects and false if the standard input stream stays open.
StopSignal String This option describes the UNIX® stop signal to send when to stop the container.
StopTimeout Integer This option displays the timeout in seconds to stop a container.
Tty Boolean This option displays true if a pseudo-tty is allocated to the container and false if not.
User String This option displays the user that runs commands inside the container where the image is used.
Volumes Key-Value map This option displays the list of volume mounts that are mounted to a container.
WorkingDir String This option displays the working directory that is inside the container where the specified commands are run.
{: caption="Available fields and data types in Config" caption-side="bottom"}
{: #table_registry_cli_list_config}

Healthcheck field details

{: #registry_cli_list_imageinspect_healthcheck}

Field Type Description
Interval Integer (64 bit) This option displays the time to wait between two health checks in nanoseconds.
Retries Integer This option displays the number of consecutive failures that need to occur to deem that a container is not working correctly.
Test Array of strings This option displays how to run the health check test. The following options are available. \n - {} inherit the health check. \n - {"NONE"} the health check is disabled. \n - {"CMD", args...} exec arguments directly. \n - {"CMD-SHELL", command} run the command with the system's default shell.
Timeout Integer (64 bit) This option displays the time to wait, in nanoseconds, before the health check fails.
{: caption="Available fields and data types in Health check" caption-side="bottom"}
{: #table_registry_cli_list_healthcheck}

RootFS field details

{: #registry_cli_list_imageinspect_rootfs}

Option Type Description
BaseLayer String This option displays the descriptor for the base layer in the image.
Layers Array of strings This option displays the descriptors of each image layer.
Type String This option displays the type of file system.
{: caption="Available fields and data types in RootFS" caption-side="bottom"}
{: #table_registry_cli_list_rootfs}

Example Go format commands for ibmcloud cr image-inspect

{: #registry_cli_list_imageinspect_go}

The following code examples demonstrate how you might use the formatting and filtering options.

Example 1 for ibmcloud cr image-inspect

{: #registry_cli_list_imageinspect_go1}

To display where {{site.data.keyword.IBM_notm}} Documentation is hosted for a specified {{site.data.keyword.IBM_notm}} public image, run the following ibmcloud cr image-inspect command.

ibmcloud cr image-inspect ibm_public_image --format "{{ .ContainerConfig.Labels }}"

{: pre}

The following message is an example of the output from the command:

map[doc.url:/docs/images/docker_image_ibm_public_image/ibm_public_image_starter.html]

{: screen}

Example 2 for ibmcloud cr image-inspect

{: #registry_cli_list_imageinspect_go2}

To display the exposed ports for a specified image, run the following ibmcloud cr image-inspect command.

ibmcloud cr image-inspect ibm_public_image --format "{{ .Config.ExposedPorts }}"

{: pre}

The following message is an example of the output from the command:

map[9080/tcp: 9443/tcp:]

{: screen}