跳到主要内容

ecs image

管理 ECS 镜像资源

运行 ecctl ecs image <action> -h 查看用法,或 ecctl schema ecs.image.<action> --full 获取该命令完整的结构化规格——每个参数与行为,便于 Agent 读取和填参。

create

ecctl ecs image create [flags]

创建自定义镜像

  • 类型:mutation · 风险:medium
  • 同步:等待 Available(waiter available_after_create,超时 1800s);用 --no-wait 跳过等待。
  • 通过 ClientToken 幂等。
  • 支持 --dry-run 校验。
API调用时机用途
CreateImage每次执行命令时执行资源操作。
DescribeImages未指定 --no-wait 且未指定 --dry-run轮询等待资源达到目标状态。(重复调用)
DescribeImages未指定 --no-wait 且未指定 --dry-run返回最终资源视图。(复用等待结果,不额外请求)
参数类型必填说明
--regionstringAlibaba Cloud region
--architecturestring镜像架构
--boot-modestring启动模式
--descriptionstring镜像描述
--detection-strategystring镜像检测策略
--disk-device-mappingobject创建或导入镜像时使用的磁盘设备映射
--image-familystring创建或更新镜像时关联的镜像族系
--image-versionstring镜像版本
--instancestring用作镜像源的实例 ID
--namestring镜像名称
--platformstring操作系统平台
--resource-groupstring资源组 ID
--snapshotstring用作镜像源的快照 ID
--tagkey_value标签赋值 key=value

update

ecctl ecs image update <id> [flags]

更新镜像属性或共享权限

  • 类型:mutation · 风险:medium
API调用时机用途
ModifyImageAttribute指定 --name 或指定 --description 或指定 --image-family 或指定 --boot-mode 或指定 --license-type 或指定 --status-action 或指定 --features执行资源操作。
ModifyImageSharePermission指定 --share-add 或指定 --share-remove 或指定 --launch-permission执行资源操作。
DescribeImages未指定 --no-wait读取资源视图。
DescribeImageSharePermission(指定 --share-add 或指定 --share-remove 或指定 --launch-permission)且未指定 --no-wait读取资源视图。
参数类型必填说明
--regionstringAlibaba Cloud region
--boot-modestring启动模式
--descriptionstring镜像描述
--featuresobject镜像功能开关
--image-familystring创建或更新镜像时关联的镜像族系
--launch-permissionstring镜像启动权限设置
--license-typestring许可证类型
--namestring镜像名称
--share-addstring_array加入镜像共享权限的账号 ID 列表
--share-removestring_array移除镜像共享权限的账号 ID 列表
--status-actionstring修改镜像时的目标状态

delete

ecctl ecs image delete <id> [flags]

删除镜像

  • 类型:mutation · 风险:high
  • 同步:等待 absent(waiter deleted_after_delete,超时 600s);用 --no-wait 跳过等待。
API调用时机用途
DeleteImage每次执行命令时执行资源操作。
DescribeImages未指定 --no-wait轮询等待资源达到目标状态。(重复调用)
参数类型必填说明
--regionstringAlibaba Cloud region
--forceboolean即使被实例引用也强制删除镜像(必须显式指定)(默认:false

get

ecctl ecs image get <id> [flags]

获取镜像

  • 类型:read · 风险:low
API调用时机用途
DescribeImageFromFamily指定 --family读取资源视图。
DescribeImages指定 &lt;id>读取资源视图。
DescribeImageSharePermission指定 --with-share-permission读取资源视图。
DescribeImageSupportInstanceTypes指定 --with-supported-instance-types读取资源视图。
参数类型必填说明
--regionstringAlibaba Cloud region
--action-typestring查询镜像支持实例规格时使用的操作类型
--familystring镜像族系名称
--fieldsstring要包含的资源字段,使用逗号分隔
--with-share-permissionboolean附带镜像共享权限
--with-supported-instance-typesboolean附带支持的实例规格

list

ecctl ecs image list [<ids>...] [flags]

列出镜像资源

  • 类型:read · 风险:low
API调用时机用途
DescribeImages每次执行命令时读取资源视图。
参数类型必填说明
--regionstringAlibaba Cloud region
--fieldsstring要包含的资源字段,使用逗号分隔
--filterkey_value过滤表达式 key=value
--limitinteger最多返回资源数量(默认:100
--pageinteger返回结果页码(默认:1

copy

ecctl ecs image copy <id> [flags]

跨地域复制镜像

  • 类型:mutation · 风险:medium
  • 同步:等待 Available(waiter available_after_copy,超时 3600s);用 --no-wait 跳过等待。
  • 通过 ClientToken 幂等。
API调用时机用途
CancelCopyImage指定 --cancel执行资源操作。
CopyImage未指定 --cancel执行资源操作。
DescribeImages未指定 --cancel 且未指定 --no-wait轮询等待资源达到目标状态。(重复调用)
参数类型必填说明
--regionstringAlibaba Cloud region
--cancelboolean取消正在进行的复制镜像任务
--destination-descriptionstring复制镜像的目标描述
--destination-namestring复制镜像的目标名称
--destination-regionstring复制镜像的目标地域
--encryptedboolean复制镜像时加密目标镜像
--kms-key-idstring加密目标镜像使用的 KMS 密钥 ID
--resource-groupstring资源组 ID
--tagkey_value标签赋值 key=value

export

ecctl ecs image export <id> [flags]

导出镜像到 OSS

  • 类型:mutation · 风险:medium
  • 同步:等待 Finished(waiter task_finished,超时 3600s);用 --no-wait 跳过等待。
API调用时机用途
ExportImage每次执行命令时执行资源操作。
DescribeTaskAttribute未指定 --no-wait轮询等待资源达到目标状态。(重复调用)
DescribeTaskAttribute未指定 --no-wait返回最终资源视图。(复用等待结果,不额外请求)
参数类型必填说明
--oss-bucketstring导出或导入镜像使用的 OSS 存储桶
--regionstringAlibaba Cloud region
--export-formatstring镜像导出格式
--image-formatstring镜像文件格式
--oss-prefixstring导出镜像的 OSS 对象键前缀
--role-namestring访问 OSS 使用的 RAM 角色名称

import

ecctl ecs image import [flags]

从 OSS 导入镜像

  • 类型:mutation · 风险:medium
  • 同步:等待 Available(waiter available_after_import,超时 3600s);用 --no-wait 跳过等待。
  • 通过 ClientToken 幂等。
API调用时机用途
ImportImage每次执行命令时执行资源操作。
DescribeImages未指定 --no-wait轮询等待资源达到目标状态。(重复调用)
DescribeImages未指定 --no-wait返回最终资源视图。(复用等待结果,不额外请求)
参数类型必填说明
--disk-device-mappingobject创建或导入镜像时使用的磁盘设备映射
--regionstringAlibaba Cloud region
--architecturestring镜像架构
--boot-modestring启动模式
--descriptionstring镜像描述
--detection-strategystring镜像检测策略
--image-familystring创建或更新镜像时关联的镜像族系
--image-versionstring镜像版本
--license-typestring许可证类型
--namestring镜像名称
--os-typestring操作系统类型
--platformstring操作系统平台
--resource-groupstring资源组 ID
--role-namestring访问 OSS 使用的 RAM 角色名称
--tagkey_value标签赋值 key=value