POST
/
api
/
open
/
v2
/
instance
/
save_image
保存为镜像
curl --request POST \
  --url https://www.chenyu.cn/api/open/v2/instance/save_image \
  --header 'Authorization: Bearer <token>' \
  --header 'Content-Type: application/json' \
  --data '{
  "instance_uuid": "<string>"
}'
{
  "code": 123,
  "msg": "<string>"
}

保存为镜像

将指定实例的当前状态保存为私有镜像,便于后续创建相同配置的实例。
仅在实例运行时可以保存镜像,保存镜像后,实例将会自动关机。

请求参数

instance_uuid
string
required
实例uuid

响应参数

code
integer
响应码
msg
string
响应信息

代码示例

import requests

url = "https://www.chenyu.cn/api/open/v2/instance/save_image"
headers = {
    "Authorization": "Bearer your_api_key",
    "Content-Type": "application/json"
}

data = {
    "instance_uuid": "inst_12345678-1234-1234-1234-123456789012",
    "image_name": "my-custom-image",
    "remark": "包含深度学习环境的自定义镜像"
}

response = requests.post(url, headers=headers, json=data)
result = response.json()

if result['code'] == 0:
    print("镜像保存成功")
else:
    print(f"保存失败: {result['msg']}")

响应示例

{
  "code": 0,
  "msg": "保存成功"
}

注意事项

  • 保存镜像需要一定时间,请耐心等待
  • 建议在实例关机状态下保存镜像以确保数据一致性
  • 镜像名称需要唯一,不能与已有镜像重名
  • 保存的镜像将出现在您的私有镜像列表中