A ConfigFile volume is a type of volume that stores configuration files, allowing you to inject configuration data into an Elastic Container Instance (ECI) instance. This topic describes how to mount a ConfigFile volume for an ECI instance.
Limits
In a ConfigFile volume, a single configuration file cannot exceed 32 KB in size, and the total size of all configuration files cannot exceed 60 KB.
Configuration (API)
When you call the CreateContainerGroup API operation to create an elastic container instance, you can use Volume-related parameters to specify volumes, and then use Container.VolumeMount-related parameters to mount the volumes to containers. The relevant parameters are described below. For more information, see CreateContainerGroup.
Declare a volume
When you use Volume-related parameters to specify volumes, you must first specify the types and names of the volumes. Then, you must configure other Volume-related parameters based on the value of the Volume.N.Type parameter.
|
Parameter |
Type |
Example |
Description |
|
Volume.N.Name |
String |
test-volume |
The name of the volume. |
|
Volume.N.Type |
String |
ConfigFileVolume |
Set the value to |
|
Volume.N.ConfigFileVolume.ConfigFileToPath.N.Path |
String |
test/config-test.cnf |
The path of the configuration file, relative to the mount directory. |
|
Volume.N.ConfigFileVolume.ConfigFileToPath.N.Content |
String |
bGl1bWk= |
The Base64-encoded content of the configuration file. |
|
Volume.N.ConfigFileVolume.DefaultMode |
Integer |
0644 |
The default permissions for the configuration files, specified as a four-digit octal number. For example, The permissions are described as follows:
|
|
Volume.N.ConfigFileVolume.ConfigFileToPath.N.Mode |
Integer |
0644 |
The permissions for the configuration file, specified as a four-digit octal number. If this parameter is omitted, the value of For example, The permissions are described as follows:
|
Mount volumes
After you specify volumes, you can use VolumeMount-related parameters to mount the volumes to containers.
Parameter | Type | Example | Description |
Container.N.VolumeMount.N.Name | String | test-volume | The name of volume N to be mounted to container N. This value is the value of Volume.N.Name. |
Container.N.VolumeMount.N.MountPath | String | /usr/share | The path within the container at which to mount the volume. Data in this directory is obscured by the data on the volume. |
Container.N.VolumeMount.N.SubPath | String | /usr/sub | The subdirectory of the volume. This parameter specifies different subdirectories of the same volume that the instance can mount to different subdirectories of containers. |
Container.N.VolumeMount.N.ReadOnly | Boolean | false | Specifies whether the mount directory is read-only. Default value: false. |
Container.N.VolumeMount.N.MountPropagation | String | None | The mount propagation setting of volume N. Mount propagation allows you to share volumes that are mounted to one container to other containers in the same elastic container instance, or even to other elastic container instances on the same host. Valid values:
Default value: None. |
Volumes can also be mounted to init containers. The required parameters are similar to the parameters in the preceding table. You only need to change Container to InitContainer.
Configuration (console)
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.
Declare a volume
-
In the Container Group Configurations section, expand Advanced Settings.
-
In Storage, select the Configuration Item tab and click Add.
-
Configure the parameters for the ConfigFile volume.
-
Name: The name of the ConfigFile volume.
-
Configuration File Path: The path of the configuration file relative to the mount directory.
-
Content: Enter the plaintext content of the configuration file. The console automatically Base64-encodes it.
-
Mount the volume
-
In the Container Configurations section, select a container and expand its Advanced Settings.
-
Turn on Storage and click Add.
Only volumes that you declared in the Container Group Configurations section are available to be mounted.
Select the configfile-demo volume of type Configuration Item, set the mount path in the container to
/data, and do not select the Read-only option.
If you want to mount volumes to multiple containers, select more containers and repeat the preceding operations.
Configuration example
Call the CreateContainerGroup operation to create an ECI instance and mount a ConfigFile volume to it. The following example shows the required request parameters. For more information, see CreateContainerGroup.
ContainerGroupName=test-configfile
#Declare a volume
Volume.1.Name=configfile-demo
Volume.1.Type=ConfigFileVolume
Volume.1.ConfigFileVolume.ConfigFileToPath.1.Path=test/config-test.cnf
Volume.1.ConfigFileVolume.ConfigFileToPath.1.Content=c2VydmVyLnBvcnQgPSA4MDgw
Volume.1.ConfigFileVolume.DefaultMode=0644
#Mount the volume to a 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=configfile-demo
Container.1.VolumeMount.1.MountPath=/data