This topic describes how to create an elastic container instance that uses local disks by specifying supported ECS instance types, and how to mount the local disk volume to containers in the instance.
API only: You can only create elastic container instances with local disks by calling API operations. The Elastic Container Instance console does not support this feature.
Local disks reside on a single physical server, which increases the risks of single points of failure (SPOFs). The durability of data stored on local disks is determined by the reliability of the associated physical server. For more information, see Limits.
Local disks are physically attached to the same server that hosts your container instance. They deliver high random IOPS, high throughput, and low latency, making them a strong fit for:
Big data processing workloads (such as Hadoop and Spark)
High-IOPS database workloads (such as Cassandra and MongoDB)
Machine learning training with local scratch space
Log aggregation and analysis
Prerequisites
You must have the permissions required to call the CreateContainerGroup API operation.
You must be familiar with ECS instance types that support local disks. For more information, see Overview of instance families.
Supported ECS instance families
The following ECS instance families with local disks can be used to create elastic container instances:
| Instance family | Description |
|---|---|
| d1 | Big data instance family |
| d1ne | Network-enhanced big data instance family |
| i2 | Instance family with local SSDs |
| i2g | Instance family with local SSDs |
| gn5 | GPU-accelerated compute-optimized instance family |
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, see the following topics:
Step 1: Define the volume and instance type
Call the CreateContainerGroup API operation. Use the InstanceType parameter to specify an ECS instance type with local disks, and use the volume parameters to define a local disk volume.
When you set the Volume.N.EmptyDirVolume.Medium parameter to LocalRaid0, all local disks on the instance are combined into a RAID 0 array. RAID 0 stripes data across multiple disks, which maximizes total capacity and throughput. However, RAID 0 provides no data redundancy; if any single disk fails, all data in the array is lost.
| Parameter | Type | Example | Description |
|---|---|---|---|
| InstanceType | String | ecs.gn6v-c8g1.2xlarge | The ECS instance types that use local disks. Supported instance families: 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. Set this parameter to EmptyDirVolume to specify an emptyDir volume. |
| Volume.N.EmptyDirVolume.Medium | String | LocalRaid0 | The storage medium for emptyDir volume N. Set this parameter to LocalRaid0 to combine all local disks into a RAID 0 array. |
Step 2: Mount the volume to containers
After you define the local disk volume, use the volume mount parameters to mount the RAID 0 volume to a directory in each container that needs access to it.
| Parameter | Type | Example | Description |
|---|---|---|---|
| Container.N.VolumeMount.N.Name | String | localdisk | The name of the volume to mount to container N. This value must match the value of Volume.N.Name. |
| Container.N.VolumeMount.N.MountPath | String | /localdisk-test | The directory path where the volume is mounted inside the container. Any existing data in this directory inside the container will be hidden by the mounted volume. Make sure that this value is correct. |
Sample configuration
The following example creates an elastic container instance with a local disk volume and mounts it to a container.
ContainerGroupName=test-localdisk
# Specify the ECS instance type with local disks.
InstanceType=ecs.i2g.2xlarge
# Define the RAID 0 volume composed of local disks.
Volume.1.Name=localdisk
Volume.1.Type=EmptyDirVolume
Volume.1.EmptyDirVolume.Medium=LocalRaid0
# Mount 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-testVerify the RAID 0 volume
After the instance is created, connect to the elastic container instance and run the df -h command to verify that the RAID 0 volume is mounted correctly. Local disks are combined into a RAID 0 array and mounted to the specified /localdisk-test directory. The RAID device name may vary depending on the instance type and configuration, such as /dev/md0 or /dev/md127.
