You can mount volumes to elastic container instances as persistent storage. This topic describes the volumes that can be mounted to elastic container instances and how to configure the volumes.
Volume type
Files in containers are temporarily stored on disks. Temporary storage causes the following issues to applications that run in containers.
If a container fails, the files that generated during the running of the container are not retained when the container is rebuilt. The files are lost.
When multiple containers run in the same elastic container instance, files cannot be shared among the containers.
To address the preceding issues, Elastic Container Instance uses volumes as persistent storage. The following table describes the type of volumes that Elastic Container Instance supports.
Volume type | Description | API mode | Console mode |
Disks | Disks are block-level storage products provided by Alibaba Cloud. Disks feature low latency, high performance, high durability, and high reliability. For more information, see Disks. Disks are suitable for the following scenarios:
| Supported | Not supported |
NAS | File Storage NAS (NAS) is a distributed file system provided by Alibaba Cloud. NAS supports shared access and auto scaling. NAS features high reliability and high performance. For more information, see What is NAS? NAS is suitable for the following scenarios:
| Supported | Supported |
OSS | Object Storage Service (OSS) is a secure, cost-effective, and highly reliable Alibaba Cloud storage service that allows you to store large volumes of unstructured data, such as images and audio and video data. For more information, see What is OSS? OSS volumes are suitable for the following scenarios:
| Supported | Supported |
EmptyDir | emptyDir volumes are temporary directories that are used to temporarily store data and share data among containers. The data in an emptyDir volume is cleared when the instance is deleted. Important emptyDir volumes are temporary storage. When an elastic container instance to which an emptyDir volume is mounted is restarted, the data stored in the emptyDir volume is also cleared. | Supported | Supported |
ConfigFile | The configuration file that is used to pass in configuration data of an elastic container instance. | Supported | Supported |
Configuration description
To use a volume, you need to specify the volume and then mount the volume to a container.
API mode
When you call the CreateContainerGroup API operation to create an elastic container instance, you can specify the name and type of the volume by using the Volume.N.Name and Volume.N.Type parameters. Then, you need to configure more parameters based on the value of Volume.N.Type.
Value of Volume.N.Type | Description | References |
EmptyDirVolume | An emptyDir volume, which indicates a temporary directory. | |
ConfigFileVolume | A ConfigFile volume, which indicates a configuration file. | |
NFSVolume | An NFS volume, which indicates a network file system, such as a NAS file system. | |
FlexVolume | A volume that is mounted by using the FlexVolume plug-in. These volumes include disks, NAS file systems, and OSS buckets. |
DiskVolume is also a valid value of Volume.N.Type, which indicates a disk volume. We do not recommend that you use the DiskVolume value. If you want to mount a disk, we recommend that you use the FlexVolume value.
After you specify a volume, you can use Container.VolumeMount-related parameters to mount the volume to a container.
Console mode
When you create an elastic container instance on the Elastic Container Instance buy page, you can specify volumes in the Container Group Configurations section and then mount the volumes to containers in the Container Configurations section.
Click Advanced Settings in the Container Group Configurations section and specify a volume.
The Elastic Container Instance console supports only the following volume type:
Configuration item (ConfigFile)
Temporary directories (emptyDir)
NAS persistence (NFS)
OSS persistence (FlexVolume)
In the Container Configurations section, click Advanced Settings next to a container to mount the volume to the container.