All Products
Search
Document Center

Elastic Container Instance:Specify ECS instance types that use local disks to create an elastic container instance

Last Updated:Nov 06, 2023

This topic describes how to specify ECS (Elastic Compute Service) instance types that use local disks to create an elastic container instance and attach a local disk to the elastic container instance.

Description of the ECS instance families

Local disks reside on the same physical server as the elastic container instance to which the disks are attached. Local disks are cost-effective and provide high random IOPS, high throughput, and low latency. Local disks reside on a single physical server, which increases the risks of single points of failure (SPOFs). For more information, see Local disks.

Important

Local disks reside on a single physical server, which increases the risks of SPOFs. The durability of data stored on local disks is determined by the reliability of the associated physical server. For more information, see Limits.

The following ECS instance families with local disks can be used to create elastic container instances:

  • d1, big data instance family

  • d1ne, big data instance family with enhanced network performance

  • i2, instance family with local SSDs

  • i2g, instance family with local SSDs

  • gn5, GPU-accelerated compute-optimized instance family

Note

gn5 is a GPU-accelerated instance family. If you select this instance family, you must specify GPU-related parameters in addition to local disk-related parameters.

For more information about ECS instance types, see the following topics:

Configuration description

Note

If you want to specify ECS instance types that use local disks to create an elastic container instance and attach a local disk to the elastic container instance, you can only call API operations instead of using the Elastic Container Instance console.

When you call the CreateContainerGroup API operation to create an elastic container instance, you can use the InstanceType parameter to specify ECS instance types and the volume-related parameters to attach a local disk. The following table describes relevant parameters. For more information, see CreateContainerGroup.

  • Create an elastic container instance that uses a local disk and specify a local disk as a volume

    Parameter

    Type

    Example

    Description

    InstanceType

    String

    ecs.gn6v-c8g1.2xlarge

    The ECS instance types that use local disks. The following ECS instance families that use local disks can be used to create elastic container instances: d1, d1ne, i2, i2g, and gn5.

    You can specify up to five ECS instance types at a time. Separate multiple instance types with commas (,). Example: ecs.d1.2xlarge,ecs.d1ne.2xlarge.

    Volume.N.Name

    String

    localdisk

    The name of volume N.

    Volume.N.Type

    String

    EmptyDirVolume

    The type of volume N. A value of EmptyDirVolume specifies an emptyDir volume.

    Volume.N.EmptyDirVolume.Medium

    String

    LocalRaid0

    The storage medium for emptyDir volume N. A value of LocalRaid0 specifies RAID 0 that is formed into by local disks.

  • Attach RAID 0 to the elastic container instance

    Parameter

    Type

    Example

    Description

    Container.N.VolumeMount.N.Name

    String

    localdisk

    The name of volume N to be attached to container N. This value is the same as the value of Volume.N.Name.

    Container.N.VolumeMount.N.MountPath

    String

    /localdisk-test

    The directory in which volume N is attached.

    Data in this directory is overwritten by the data on the volume. Make sure that this value is correct.

Sample configurations:

  1. Create an elastic container instance that uses a local disk.

    The following code provides an example of the parameters that you need to specify when you call the CreateContainerGroup API operation to create an elastic container instance that uses a local disk.

    ContainerGroupName=test-localdisk
    # Specifies the ECS instance types that use local disks.
    InstanceType=ecs.i2g.2xlarge
    # Specifies the RAID 0 volume that is formed into by local disks.
    Volume.1.Name=localdisk
    Volume.1.Type=EmptyDirVolume
    Volume.1.EmptyDirVolume.Medium=LocalRaid0
    # Attach the RAID 0 volume to the container.
    Container.1.Name=nginx
    Container.1.Image=registry-vpc.cn-hangzhou.aliyuncs.com/eci_open/nginx:1.14.2
    Container.1.VolumeMount.1.Name=localdisk
    Container.1.VolumeMount.1.MountPath=/localdisk-test
  2. Check the attached RAID 0.

    Connect to the elastic container instance. Run the df -h command to view the information about the attached RAID 0. Local disks form into RAID 0 (/dev/md0), and RAID 0 is attached to the specified /localdisk-test directory.

    本地盘