Working with image registries and repositories

Snowpark Container Services provides an OCIv2-compliant image registry service and a storage unit call repository to store images. You can use the following Snowflake CLI commands to manage Snowpark Container Services image registries and repositories:

For more information about Snowpark Container Services image registries and repositories, see Snowpark Container Services: Working with an image registry and repository.

Manage image registries

Snowflake CLI lets you perform the following tasks with Snowpark Container Services image repositories:

For common operations, such as listing or dropping, Snowflake CLI uses snow object commands as described in Managing Snowflake objects.

Get environment tokens for registry authentication

You can use the spcs image-registry token command to return the token associated with the specified connection that you can use to authenticate with the registry.

snow spcs image-registry token --connection mytest
Copy
+----------------------------------------------------------------------------------------------------------------------+
| key        | value                                                                                                   |
|------------+---------------------------------------------------------------------------------------------------------|
| token      | ****************************************************************************************************    |
|            | ****************************************************************************************************    |
| expires_in | 3600                                                                                                    |
+----------------------------------------------------------------------------------------------------------------------+

You can then use that token to log in to a Docker container by piping it to the docker login command, similar to the following:

snow spcs image-registry token --format=JSON | docker login <org>-<account>.registry.snowflakecomputing.com -u 0sessiontoken --password-stdin
Copy

Log in to an image registry

The spcs image-registry login logs you into an image repository with the credentials specified for your connection. Before logging in, you must meet the following prerequisites:

  • Docker Desktop must be installed because the command uses docker to log in to Snowflake.

  • The current role must have READ privileges for the image repository in the account to get the registry URL.

To log in to an image registry with your account credentials, use the the following:

snow spcs image-registry login
Copy
Login Succeeded

Retrieve the URL for an image registry

The spcs image-registry url command returns a URL for an image repository. The current role must have READ privileges for the image repository in the account to get the registry URL.

To get the URL for a repository, do the following:

snow spcs image-registry url
Copy
<orgname-acctname>.registry.snowflakecomputing.com

Manage image repositories

Snowflake CLI lets you perform the following tasks with Snowpark Container Services image repositories:

For common operations, such as listing or dropping, Snowflake CLI uses snow object commands as described in Managing Snowflake objects.

Create an image repository

The spcs image-repository create command creates a new image repository in the current schema.

To create an image repository, enter a command similar to the following:

snow spcs image-repository create tutorial_repository
Copy
+-------------------------------------------+
| key    | value                            |
|--------+----------------------------------|
| status | Statement executed successfully. |
+-------------------------------------------+

Retrieve the URL for an image repository

The spcs image-repository url command gets the URL for an image repository.

To get the URL, enter a command similar to the following:

snow spcs image-repository url tutorial_repository
Copy
<orgname-acctname>.registry.snowflakecomputing.com/tutorial_db/data_schema/tutorial_repository

List tags and images in an image repository

The spcs image-repository list-images and spcs image-repository list-images commands let you get the images and tags, respectively, for an image repository.

To list the images in a repository, enter a command similar to the following, which lists the images in a repository named images in the my_db database:

snow spcs image-repository list-images images --database my_db
Copy
+--------------------------------------------------------+
| image                                                  |
|--------------------------------------------------------|
| /MY_DB/PUBLIC/images/cp-enterprise-control-center      |
| /MY_DB/PUBLIC/images/cp-kafka-rest                     |
| /MY_DB/PUBLIC/images/cp-schema-registry                |
| /MY_DB/PUBLIC/images/cp-server-connect-datagen         |
| /MY_DB/PUBLIC/images/cp-server                         |
| /MY_DB/PUBLIC/images/cp-zookeeper                      |
| /MY_DB/PUBLIC/images/oktaexample                       |
+--------------------------------------------------------+

To list the tags for a specific image in a repository, enter a command similar to the following:

snow spcs image-repository list-tags images --image_name "MY_DB/PUBLIC/images/cp-schema-registry" --database my_db
Copy
+----------------------------------------------------+
| tag                                                |
|----------------------------------------------------|
| /MY_DB/PUBLIC/images/cp-schema-registry:7.3.0      |
+----------------------------------------------------+