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 snow 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 snow 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 following:

snow spcs image-registry login
Copy
Login Succeeded

Retrieve the URL for an image registry

The snow 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 snow 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 snow 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 snow spcs image-repository list-images command lets you get the images and tags for an image repository.

To list the images and tags 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
+----------------------------+---------------+---------+-------------------------------------------------+-----------------------------------------+
| created_on                 | image_name    | tags    | digest                                          | image_path                              |
|----------------------------+---------------+---------+-------------------------------------------------+-----------------------------------------|
| 2024-10-11 14:23:49-07:00  | echo_service  | latest  | sha256:a8a001fef406fdb3125ce8e8bf9970c35af7084  | my_db/test_schema/images/echo_service:  |
|                            |               |         | fc33b0886d7a8915d3082c781                       | latest                                  |
| 2024-10-14 22:21:14-07:00  | test_counter  | latest  | sha256:8cae96dac29a4a05f54bb5520003f964baf67fc  | my_db/test_schema/images/test_counter:  |
|                            |               |         | 38dcad3d2c85d6c5aa7381174                       | latest                                  |
+----------------------------+---------------+---------+-------------------------------------------------+-----------------------------------------+