使用镜像注册表和镜像仓库
Snowpark Container Services provides an OCIv2 (https://github.com/opencontainers/distribution-spec/blob/main/spec.md)-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.
管理镜像注册表
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.
获取用于注册表身份验证的环境令牌
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.
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:
登录镜像注册表
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 (https://www.docker.com/products/docker-desktop/) must be installed because the command uses docker to log in to Snowflake.
- 当前角色必须具有账户中镜像仓库的 READ 权限才能获取注册表 URL。
要使用您的账户凭据登录到镜像注册表,请使用以下命令:
检索镜像注册表的 URL¶
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.
要获取镜像仓库的 URL,请执行以下操作:
管理镜像仓库
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.
创建镜像仓库
The snow spcs image-repository create command creates a new image repository in the current schema.
要创建镜像仓库,请输入类似下面的命令:
根据项目定义创建和部署镜像仓库
You can deploy an image repository to a stage by creating a snowflake.yml project definition file and executing the snow spcs image-repository deploy command.
The following shows a sample snowflake.yml project definition file:
下表描述了计算池项目定义的属性。
Image repository project definition properties
| Property | Definition |
|---|---|
type required、string | Must be image-repository. |
identifier optional、string | 实体的 Snowflake 标识符。该值可以采用以下形式:
Both unquoted and quoted identifiers are supported. To use quoted identifiers, include the surrounding quotes in the YAML value (for example,
Note An error occurs if you specify a |
要创建和部署镜像仓库,请执行以下操作:
-
将当前目录更改为包含项目定义文件的目录。
-
Run a
snow spcs image-repository deploycommand similar to the following:
检索镜像仓库的 URL¶
The snow spcs image-repository url command gets the URL for an image repository.
要获取 URL,请输入类似下面的命令:
列出镜像仓库中的标签和镜像
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: