All Products
Search
Document Center

Elastic Container Instance:Configure a fixed IP for an ECI instance

Last Updated:Jun 20, 2026

By default, the IP address of an ECI instance is released when the instance is released. If your application requires a persistent IP address, you can enable the fixed IP address feature. This feature retains the IP address for a specified period after the instance is released. Within this period, you can reassign the retained IP address to a new instance to ensure IP continuity for your service. This topic describes how to configure an ECI instance to use a fixed IP address.

How it works

By default, when you create an ECI instance, the system randomly assigns an IP address from the CIDR block of the specified vSwitch. When the instance is released, its IP address is also released, and any new instance receives a different IP address. Certain business scenarios, such as services exposed directly through an IP address, require a persistent IP address to ensure business continuity.

To address this requirement, ECI provides the fixed IP address feature. When you create an ECI instance with this feature enabled, the system assigns two IP addresses from the CIDR block of the specified vSwitch: a dynamic IP address (an internal, non-visible address) and a fixed IP address. After the instance is released, the system retains its fixed IP address. Within the retention period (48 hours by default), if you create a new instance with the same name, in the same vSwitch, and with the fixed IP address feature enabled, the system reassigns the retained IP address to the new instance. This ensures the service's IP address remains the same.

Parameters

When you call the CreateContainerGroup API operation to create an ECI instance, you can use parameters such as FixedIp to enable the fixed IP address feature. The following table describes the relevant parameters. For more information, see CreateContainerGroup.

Parameter

Type

Example

Description

VSwitchId

string

vsw-bp1xpiowfm5vo8o3c****

The ID of the vSwitch to which the instance belongs.

You must specify a vSwitch when you enable the fixed IP address feature.

SecurityGroupId

string

sg-2ze468xqmne3u4ak*

The ID of the security group to which the instance belongs.

You must specify a security group if a vSwitch is specified.

FixedIp

string

true

Set this parameter to true to enable the fixed IP address feature for the instance.

FixedIpRetainHour

integer

24

Specifies the retention period, in hours, for the fixed IP address after the instance is released. The default value is 48.

Example

  1. Create an ECI instance named A with the fixed IP address feature enabled.

    The following example shows the parameters for calling the CreateContainerGroup API operation to create instance A:

    RegionId=cn-beijing
    SecurityGroupId=sg-bp1daxpbz9lzpvvc****
    VSwitchId=vsw-bp1gds63lmlm7ib05****
    ContainerGroupName=test
    Container.1.Name=nginx1
    Container.1.Image=registry-vpc.cn-beijing.aliyuncs.com/eci_open/nginx:1.14.2
    FixedIp=true
  2. Verify the IP address of instance A.

    You can call the DescribeContainerGroups API operation with the returned instance ID or view the IP address in the console.

    On the ECI instance list page, you can find the internal IP address of instance A in the IP Address column, for example, 172.16.11.71.

  3. Delete instance A.

  4. Create an ECI instance named B.

    Call the CreateContainerGroup API operation with the following parameters to create instance B. The instance name and vSwitch are the same as those of instance A, and the fixed IP address feature is enabled.

    RegionId=cn-beijing
    SecurityGroupId=sg-bp1daxpbz9lzpvvc****
    VSwitchId=vsw-bp1gds63lmlm7ib05****
    ContainerGroupName=test
    Container.1.Name=nginx2
    Container.1.Image=registry-vpc.cn-beijing.aliyuncs.com/eci_open/nginx:1.15.10
    FixedIp=true
  5. Verify that the IP address of instance B is the same as that of instance A.

    On the ECI instance list page, confirm that the internal IP address of instance B in the IP Address column is the same as that of instance A (for example, 172.16.11.71).