建立一個映像組件。映像組件用於儲存您在建構映像時,常用的建構範本命令。
介面說明
介面說明
建立映像組件前,您需要注意:
僅支援建立您自訂的映像組件。
相同名稱的組件版本號不能重複,當在範本中使用組件時,可以透過名稱和版本號進行引用。
映像組件的內容大小不能超過 16 KB。支援的命令詳情,請參見映像建構服務支援的命令說明。
更多資訊,請參見映像建構概述。
調試
您可以在OpenAPI Explorer中直接運行該介面,免去您計算簽名的困擾。運行成功後,OpenAPI Explorer可以自動產生SDK程式碼範例。
調試
授權資訊
|
操作 |
存取層級 |
資源類型 |
條件關鍵字 |
關聯操作 |
|
ecs:CreateImageComponent |
create |
*ImageComponent
|
無 | 無 |
請求參數
|
名稱 |
類型 |
必填 |
描述 |
樣本值 |
| RegionId |
string |
是 |
所屬的地域 ID。您可以呼叫 DescribeRegions 查看最新的阿里雲地域列表。 |
cn-hangzhou |
| ResourceGroupId |
string |
否 |
企業資源群組 ID。 |
rg-bp67acfmxazb4p**** |
| Tag |
array<object> |
否 |
標籤列表。 |
|
|
object |
否 |
|||
| Key |
string |
否 |
標籤鍵。N 的取值範圍:1~20。一旦傳入該值,則不允許為空字串。最多支援 128 個字元,不能以 aliyun 和 acs: 開頭,不能包含 http:// 或者 https://。 |
TestKey |
| Value |
string |
否 |
標籤值。N 的取值範圍:1~20。一旦傳入該值,可以為空字串。最多支援 128 個字元,不能以 acs: 開頭,不能包含 http:// 或者 https://。 |
TestValue |
| Name |
string |
否 |
組件名稱。長度為 2~128 個字元,必須以大小寫字母或中文開頭,不能以 http:// 和 https:// 開頭。可以包含中文、英文、數字、半形冒號(:)、底線(_)、半形句號(.)或者短劃線(-)。 說明
不設定 |
testComponent |
| Description |
string |
否 |
描述資訊。長度為 2~256 個英文或中文字元,不能以 http:// 和 https:// 開頭。 |
This is description. |
| SystemType |
string |
否 |
組件支援的作業系統。 取值範圍:
預設值:Linux。 |
Linux |
| ComponentType |
string |
否 |
組件類型。支援映像建構組件和測試組件。 取值範圍:
預設值:Build。 說明
建構組件只能在建構範本中使用,測試組件只能在測試範本中使用。 |
Build |
| Content |
string |
否 |
組件內容。由多條命令組成,命令內容不能超過 16KB。支援的命令和命令格式詳情,請參見映像建構服務支援的命令說明。 |
Tasks: - Name: HelloWorld Action: RunShellCommand Properties: commandContent: echo hello world |
| ClientToken |
string |
否 |
保證請求冪等性。從您的用戶端產生一個參數值,確保不同請求間該參數值唯一。ClientToken 只支援 ASCII 字元,且不能超過 64 個字元。更多資訊,請參見如何保證冪等性。 |
123e4567-e89b-12d3-a456-426655440000 |
| ComponentVersion |
string |
否 |
組件版本號,與組件名稱配合使用,格式為 major.minor.patch,均為非負整數。 預設值:(x+1).0.0,x 為當前組件最大的 major 版本號。 |
1.0.0 |
返回參數
|
名稱 |
類型 |
描述 |
樣本值 |
|
object |
|||
| ImageComponentId |
string |
映像組件 ID。 |
ic-bp67acfmxazb4p**** |
| RequestId |
string |
請求 ID。 |
473469C7-AA6F-4DC5-B3DB-A3DC0DE3C83E |
樣本
正常返回樣本
JSON格式
{
"ImageComponentId": "ic-bp67acfmxazb4p****",
"RequestId": "473469C7-AA6F-4DC5-B3DB-A3DC0DE3C83E"
}
錯誤碼
|
HTTP status code |
錯誤碼 |
錯誤資訊 |
描述 |
|---|---|---|---|
| 400 | InvalidCommand.Component | Image component does not support component command. | |
| 400 | InvalidName.Malformed | %s | |
| 400 | InvalidDescription.Malformed | %s | |
| 400 | InvalidSystemType.NotSupportedValue | %s | |
| 400 | InvalidComponentType.NotSupportedValue | %s | |
| 400 | InvalidContent.LengthExceeded | %s | |
| 400 | InvalidImageTemplateCommandSize.ExceededMaxNumber | %s | |
| 400 | InvalidImageTemplateCommand.NotSupported | %s | |
| 400 | InvalidCommandContent.RUN | %s | |
| 400 | InvalidCommandContent.ENV | %s | |
| 400 | InvalidCommandContent.WORKDIR | %s | |
| 400 | InvalidCommandContent.COPY | %s | |
| 400 | InvalidCommandContent.USER | %s | |
| 400 | InvalidCommandContent.CMD | %s | |
| 400 | InvalidCommandContent.ENTRYPOINT | %s | |
| 400 | MissingParameter.Content | %s | |
| 400 | EmptyCommandContent.RUN | %s. | |
| 400 | EmptyCommandContent.ENV | %s. | |
| 400 | EmptyCommandContent.LABEL | %s. | |
| 400 | EmptyCommandContent.COPY | %s. | |
| 400 | EmptyCommandContent.ENTRYPOINT | %s. | |
| 400 | EmptyCommandContent.CMD | %s. | |
| 400 | NotEmptyCommandContent.RESTART | %s. | |
| 400 | EmptyCommandContent.WORKDIR | %s. | |
| 400 | EmptyCommandContent.USER | %s. | |
| 400 | QuotaExceed.ImageComponent | %s. | |
| 400 | InvalidParameter.Content | %s. | |
| 400 | InvalidImage.OsTypeUnsupported | The specified base image does not support image building. | |
| 400 | InvalidParameter.ComponentVersion | The specified ComponentVersion is invalid. | |
| 403 | InvalidComponentVersion.Exist | The specified ComponentVersion does exist with the specified Name. | |
| 403 | InvalidOperation.NoPermissionCreateServiceLinkedRole | You are not authorized to create Service-linked role. The system will automatically create it when the API is called for the first time. Check your RAM policies, and ensure that you are using the correct credentials. | |
| 404 | InvalidResourceGroup.NotFound | The ResourceGroup provided does not exist in our records. | |
| 404 | NotSupportedCommand.FROM | %s |
訪問錯誤中心查看更多錯誤碼。
變更歷史
更多資訊,參考變更詳情。