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
+----------------------------------------------------------------------------------------------------------------------+
| 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
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 the following:
snow spcs image-registry login
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
<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
+-------------------------------------------+
| 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
<orgname-acctname>.registry.snowflakecomputing.com/tutorial_db/data_schema/tutorial_repository