CreateImageBuild

Updated at:

Builds a custom image based on the specified configuration. After the build succeeds, the image is added to the custom images of the current workspace.

Operation description

Request description.

Try it now

Try this API in OpenAPI Explorer, no manual signing needed. Successful calls auto-generate SDK code matching your parameters. Download it with built-in credential security for local usage.

Test

RAM authorization

The table below describes the authorization required to call this API. You can define it in a Resource Access Management (RAM) policy. The table's columns are detailed below:

  • Action: The actions can be used in the Action element of RAM permission policy statements to grant permissions to perform the operation.

  • API: The API that you can call to perform the action.

  • Access level: The predefined level of access granted for each API. Valid values: create, list, get, update, and delete.

  • Resource type: The type of the resource that supports authorization to perform the action. It indicates if the action supports resource-level permission. The specified resource must be compatible with the action. Otherwise, the policy will be ineffective.

    • For APIs with resource-level permissions, required resource types are marked with an asterisk (*). Specify the corresponding Alibaba Cloud Resource Name (ARN) in the Resource element of the policy.

    • For APIs without resource-level permissions, it is shown as All Resources. Use an asterisk (*) in the Resource element of the policy.

  • Condition key: The condition keys defined by the service. The key allows for granular control, applying to either actions alone or actions associated with specific resources. In addition to service-specific condition keys, Alibaba Cloud provides a set of common condition keys applicable across all RAM-supported services.

  • Dependent action: The dependent actions required to run the action. To complete the action, the RAM user or the RAM role must have the permissions to perform all dependent actions.

Action

Access level

Resource type

Condition key

Dependent action

paiimage:CreateImageBuild

create

*All Resource

*

None None

Request syntax

POST /api/v1/imagebuilds HTTP/1.1

Request parameters

Parameter

Type

Required

Description

Example

ClientToken

string

No

The idempotency parameter.

123e4567-e89b-12d3-a456-426655440000

body

object

No

The request body.

Accessibility

string

No

The visibility.

  • PUBLIC: Public.

  • PRIVATE: Private.

Valid values:

  • PUBLIC :

    PUBLIC

  • PRIVATE :

    PRIVATE

PUBLIC

WorkspaceId

string

Yes

The workspace ID.

12345

Resource

object

Yes

The runtime resources for the task.

EcsSpec

string

No

The pay-as-you-go resource specification. This parameter is required when you use a public resource group.

ecs.c6.large

ResourceConfig

object

No

The resource configuration. This parameter is required when you use subscription resources and must be left empty when you use a public resource group.

CPU

string

No

The number of CPU cores.

4

Memory

string

No

The memory capacity.

8Gi

ResourceId

string

No

The resource quota ID. This parameter applies only to subscription resources. Do not set this parameter when you use pay-as-you-go resources.

quotaadzoqup693z

ResourceType

string

No

The subscription resource type. Only Lingjun resources are supported. This parameter is required when you use subscription resources.

Valid values:

  • Lingjun :

    Lingjun

Lingjun

UserVpc

object

No

The user VPC information. This parameter is required when you use a public resource group.

VpcId

string

No

The VPC ID. When the build task accesses an ACR Enterprise Edition instance, you must specify a VPC that is added to the access control list of the ACR instance.

vpc-abcdef**

SwitchId

string

No

The vSwitch ID. This parameter is optional.

vs-abcdef**

SecurityGroupId

string

No

The security group ID. This parameter is required when you specify the VPC configuration.

sg-abcdef**

ExtendedCidrs

array

No

The extended CIDR blocks.

  • If the vSwitch ID is empty, this parameter is optional and the system automatically retrieves all CIDR blocks under the VPC.

  • If the vSwitch ID is not empty, this parameter is required. We recommend that you specify all CIDR blocks under the VPC.

string

No

The extended CIDR block.

10.0.0.0/24

DefaultRoute

string

No

The default routing.

eth1

TargetRegistry

object

Yes

The target image service configuration.

InstanceId

string

No

The image service instance ID. This parameter is required when you use ACR as the image service.

cri-**abcd

Type

string

Yes

Only ACR Enterprise Edition is supported as the target image service.

AcrEnterprise

OverwriteImageTag

boolean

No

Specifies whether to overwrite an existing image version in the image repository.

BuildConfig

object

Yes

The build configuration. Specifies the content of the Dockerfile to be built.

Dockerfile

string

No

The content of the Dockerfile to be built.

FROM ubuntu:18:04 RUN pip3 install numpy==1.19.5

BuildType

string

Yes

The build type. Valid values:

  • PackageInstallation: Installs software packages based on a specified image.

  • CustomDockerfile: Uses a custom Dockerfile.

PackageInstallation

DockerfilePath

string

No

The Dockerfile path, which is a relative path to the mounted context path. Example: docker/Dockerfile. If the mount path is /mnt/data/, the file is located at /mnt/data/docker/Dockerfile.

docker/Dockerfile

RegistryAuths

object

No

The authentication information for a private image registry. You can specify the authentication information for an ACR image registry that does not belong to the current user. Format: {"user_registry_domain":{"Auth":"base64 encoded auth"}}.

{ "user-test-registry-vpc.cn-wulanchabu.cr.aliyuncs.com": { "Auth": "dXNlcjp0ZXN0" } }

DataSources

array<object>

No

The list of data sources.

object

No

DataSourceId

string

No

The ID of the dataset in the workspace. Example: d-************zbs.

d-************zbs

Uri

string

No

The storage path, including the endpoint. This parameter is mutually exclusive with DataSourceId. Example: oss://{bucket-name}.oss-{region}-internal.aliyuncs.com/{subPath}/.

oss://{bucket-name}.oss-{region}-internal.aliyuncs.com/{subPath}/

MountPath

string

No

The mount path. Example: /mnt/data/.

/mnt/data/

MountAccess

string

No

The read and write permissions. Valid values: RW (default) and RO.

RO

Options

string

No

The custom mount property for the custom dataset. Only OSS is supported. Example: {"fs.oss.download.thread.concurrency":"10"}.

{"fs.oss.download.thread.concurrency":"10"}

DataSourceVersion

string

No

The dataset version. If you specify this parameter, you must also specify DataSourceId. Example: v1.

v1

RegionId

string

No

The region ID.

cn-wulanchabu

ImageBuildJobName

string

No

The name of the image build job.

build-my-image

Image

object

Yes

The image metadata.

Name

string

Yes

The naming rules are as follows:

  • The name must be 1 to 50 characters in length.

  • The name can contain lowercase letters, digits, and hyphens (-), and must start with a letter.

  • The name must be unique within the same workspace.

test-v1

Description

string

No

The image description.

Build test image

Uri

string

Yes

The image URI.

user-test-registry-vpc.cn-wulanchabu.cr.aliyuncs.com/pai-test/pai-test:test-v1

Labels

array<object>

No

The image labels.

object

No

Key

string

No

The key of the image label.

key1

Value

string

No

The value of the image label.

value1

ImageBuildJobTags

object

No

The custom tags for the image build job.

{"labelKey":"labelValue"}

Response elements

Element

Type

Description

Example

object

All return values are in JSON format.

ImageBuildId

string

The image build ID.

build-****ks92

ImageBuildJobId

string

The build job ID.

dlc-****ks92

Examples

Success response

JSON format

{
  "ImageBuildId": "build-****ks92",
  "ImageBuildJobId": "dlc-****ks92"
}

Error codes

See Error Codes for a complete list.

Release notes

See Release Notes for a complete list.