Skip to Content
GPU 接口文档实例镜像发布镜像到社区
GPU API 接口

发布镜像到社区

接口说明

将自制镜像发布到社区镜像市场,供其他用户使用。可设置为免费或付费。

POSThttps://api.compshare.cnActionPublishCompShareImage

使用限制

  • 容器镜像制作的自制镜像可以发布到社区。虚机镜像不支持发布。
  • 镜像必须处于 Available 状态。
  • 发布后镜像进入审核流程。

请求参数

名称类型必填描述示例值
ActionString接口名称PublishCompShareImage
RegionString地域cn-wlcb
CompShareImageIdString要发布的镜像 IDcompshareImage-xxxx
GroupIdString版本组 ID。更新已有社区镜像时传入group-xxxx
CommunityImageNameString社区镜像显示名称我的AI环境
VersionNameString版本名称,必须符合版本号格式(如 v1.0v1.0
VersionDescString版本描述首次发布
PriceFloat价格(元/小时),0 表示免费0
CoverString封面图(Base64)
TagsArray of String标签列表["深度学习","PyTorch"]
DescriptionString镜像描述预装PyTorch 2.1
ReadmeString使用说明(富文本)
SoftwaresObject软件环境信息;Applications 字段使用字符串数组{"Framework":"PyTorch","Applications":["JupyterLab"]}
SoftwarePortsArray of Object软件访问端口数组,每项包含 SoftwarePort[{"Software":"JupyterLab","Port":8888}]
FirewallPortsArray of Integer防火墙开放端口数组[22,8888]
SupportedGpuTypesArray of String支持的 GPU 类型["4090","A100"]
AutoStartBoolean是否支持自启动true

响应参数

名称类型描述示例值
ActionString响应名称PublishCompShareImageResponse
RetCodeInteger返回码,0 为成功0

请求示例

Python(使用 UCloud SDK)

from ucloud.core import exc from ucloud.client import Client def main(): client = Client({ "region": "cn-wlcb", "public_key": "my_public_key", # 替换为你的公钥(控制台 账户中心 → API 密钥:https://console.compshare.cn/uaccount/api_manage) "private_key": "my_private_key", # 替换为你的私钥 "base_url": "https://api.compshare.cn", }) try: resp = client.ucompshare().publish_comp_share_image({ "CompShareImageId": "compshareImage-xxxx", # 镜像 ID,通过 DescribeCompShareImages 获取 "CommunityImageName": "我的AI环境", "VersionName": "v1.0", "Price": 0, "Tags": ["深度学习", "PyTorch"], "Description": "预装PyTorch 2.1和CUDA 12.1", "SoftwarePorts": [{"Software": "JupyterLab", "Port": 8888}], "FirewallPorts": [22, 8888], }) print("发布成功,等待审核") except exc.UCloudException as e: print(e) if __name__ == "__main__": main()

Go(使用 UCloud SDK)

package main import ( "fmt" "github.com/ucloud/ucloud-sdk-go/services/ucompshare" "github.com/ucloud/ucloud-sdk-go/ucloud" "github.com/ucloud/ucloud-sdk-go/ucloud/auth" ) func main() { cfg := ucloud.NewConfig() cfg.Region = "cn-wlcb" cfg.BaseUrl = "https://api.compshare.cn" credential := auth.NewCredential() credential.PublicKey = "my_public_key" // 替换为你的公钥(控制台 账户中心 → API 密钥:https://console.compshare.cn/uaccount/api_manage) credential.PrivateKey = "my_private_key" // 替换为你的私钥 client := ucompshare.NewClient(&cfg, &credential) req := client.NewPublishCompShareImageRequest() req.CompShareImageId = ucloud.String("compshareImage-xxxx") // 镜像 ID,通过 DescribeCompShareImages 获取 req.CommunityImageName = ucloud.String("我的AI环境") req.VersionName = ucloud.String("v1.0") _, err := client.PublishCompShareImage(req) if err != nil { fmt.Printf("发布失败: %s\n", err) return } fmt.Println("发布成功,等待审核") }

响应示例

{ "Action": "PublishCompShareImageResponse", "RetCode": 0 }
Last updated on