Elastic container instances support volumes for persistent storage. This topic describes the supported volume types and their configuration.
Volumes
Files in a container are temporarily stored on disk, which causes the following problems for applications:
-
When a container crashes, its files are lost when the container is recreated.
-
Multiple containers in the same elastic container instance cannot share files.
To address these issues, Elastic Container Instance (ECI) uses volumes. The following volume types are supported:
|
Type |
Description |
OpenAPI |
Console |
|
cloud disk |
A cloud disk is a block-level storage product provided by Alibaba Cloud. It features low latency, high performance, persistence, and high reliability. For more information, see Cloud disk overview. cloud disk volumes are suitable for the following use cases:
|
Supported |
Not supported |
|
NAS |
File Storage NAS is a distributed file system provided by Alibaba Cloud that features shared access, elastic scaling, high reliability, and high performance. For more information, see File Storage NAS overview. NAS volumes are suitable for the following use cases:
|
Supported |
Supported |
|
OSS |
Object Storage Service (OSS) is a service provided by Alibaba Cloud that offers massive, secure, cost-effective, and highly reliable storage. It is suitable for storing unstructured data, such as images, audio, and videos. For more information, see Object Storage Service overview. An OSS volume is suitable for the following use cases:
|
Supported |
Supported |
|
emptyDir |
An emptyDir volume is a temporary directory used to store transient data and share data between containers. The data in an emptyDir volume is lost when the instance is deleted. Important
Restarting an elastic container instance also clears the data in the emptyDir volume. |
Supported |
Supported |
|
ConfigFile |
A ConfigFile volume injects configuration data into an elastic container instance. |
Supported |
Supported |
Configuration
To use a volume, first declare it, and then mount it to a container.
OpenAPI
When calling the CreateContainerGroup operation, use the Volume.N.Name and Volume.N.Type parameters to define a volume. The value of Volume.N.Type determines the volume type, and each type requires specific additional parameters.
|
Volume.N.Type value |
Description |
References |
|
EmptyDirVolume |
An emptyDir volume, which is a temporary directory. |
|
|
ConfigFileVolume |
A ConfigFile volume, which is a configuration file. |
|
|
NFSVolume |
An NFS volume, which is a network file system such as NAS. |
|
|
FlexVolume |
The FlexVolume plug-in extends storage capabilities, allowing you to mount cloud disks, NAS file systems, and OSS buckets. |
DiskVolume is also a valid value for Volume.N.Type, which indicates a cloud disk volume. However, this value is no longer recommended. Use FlexVolume to mount a cloud disk instead.
After declaring a volume, use the Container.VolumeMount parameters to mount it to a container.
Console
When creating an ECI instance on the Elastic Container Instance buy page, declare volumes in the Container Group Configurations section and mount them to containers in the Container Configurations section.
-
In the Container Group Configurations section, go to the Advanced Settings area and declare a volume.
In the Storage area, select the NAS Persistence tab and click + Add. Configure a volume name (for example,
nas-demo), a NAS mount point (for example,37f3848bfd-dfh88.cn-shanghai.nas.aliyuncs.com), and a path (for example,/share). You can select the Read-only checkbox if needed.Currently, you can configure only the following volume types in the console:
-
ConfigFile
-
emptyDir
-
NAS persistence (NFS)
-
OSS persistence (FlexVolume)
-
-
In the Container Configurations section, go to the Advanced Settings of a container to mount the volume.
In the Storage area, enable the storage switch. Select the nas-demo volume (type: NAS persistence). Set the mount path in the container to
/dataand the subpath in the volume to/test. Do not select the Read-only checkbox.