#Local Volume Management

Overview

After a container managed by iSula is destroyed, all data in the container is destroyed. If you want to retain data after the container is destroyed, a data persistence mechanism is required. iSula allows files, directories, or volumes on a host to be mounted to a container at runtime. You can write the data to be persisted to the mount point in the container. After the container is destroyed, the files, directories, and volumes on the host are retained. If you need to delete a file, directory, or volume on the host, you can manually delete the file or directory, or run the iSula command to delete the volume. Currently, the iSula supports only local volume management. Local volumes are classified into named volumes and anonymous volumes. A volume whose name is specified by a user is called a named volume. If a user does not specify a name for a volume, iSula automatically generates a name (a 64-bit random number) for the volume, that is, an anonymous volume.

The following describes how to use iSula to manage local volumes.

Precautions

  • The volume name contains 2 to 64 characters and complies with the regular expression ^[a-zA-Z0-9][a-zA-Z0-9_.-]{1,63}$. That is, the first character of the volume name must be a letter or digit, and other characters can be letters, digits, underscores (_), periods (.), and hyphens (-).
  • During container creation, if data exists at the mount point of the container corresponding to the volume, the data is copied to the volume by default. If the iSula breaks down or restarts or the system is powered off during the copy process, the data in the volume may be incomplete. In this case, you need to manually delete the volume or the data in the volume to ensure that the data is correct and complete.

Usage

Using the -v Option to Mount Data

Format

isula run -v [SRC:]DST[:MODE,MODE...] IMAGE

Functions

When you create and run a container, use the -v/–volume option to mount the files, directories, or volumes on the host to the container for data persistence.

Parameter Description

  • SRC: Path of the file, directory, or volume to be mounted on the host. If the value is an absolute path, a file or folder on the host is mounted. If the value is a volume name, a volume is mounted. If this parameter is not specified, an anonymous volume is mounted. If a folder or volume does not exist, iSula creates a folder or volume and then mounts it.
  • DST: Mount path in the container. The value must be an absolute path.
  • MODE: When the source to be mounted is a directory or file, the valid parameters are ro, rw, z, Z, private, rprivate, slave, rslave, shared, and rshared. Only one parameter of the same type can be configured. If the source is a volume, the valid parameters are ro, rw, z, Z, and nocopy. Only one parameter of the same type can be configured. Use commas (,) to separate multiple attributes. The parameters are described as follows:
ParameterDescription
roThe mount point in the container is mounted in read-only mode.
rwThe mount point in the container is mounted in read/write mode.
zIf SELinux is enabled, add the SELinux share label during mounting.
ZIf SELinux is enabled, add the SELinux private label during mounting.
privateThe mount point in the container is mounted in private propagation mode.
rprivateThe mount point in the container is recursively mounted in private propagation mode.
slaveThe mount point in the container is mounted in subordinate propagation mode.
rslaveThe mount point in the container is recursively mounted in subordinate propagation mode.
sharedThe mount point in the container is mounted in shared propagation mode.
rsharedThe mount point in the container is recursively mounted in shared propagation mode.
nocopyData at the mount point is not copied. If this parameter is not set, data is copied by default. In addition, if data already exists in the volume, the data will not be copied.

Examples

Run the container based on BusyBox, create or mount a volume named vol to the /vol directory of the container, and set the mount point to read-only. In addition, if data exists at the mount point in the container, the data is not copied.

isula run -v vol:/vol:ro,nocopy busybox

Using the –mount Option to Mount Data

Format

isula run --mount [type=TYPE,][src=SRC,]dst=DST[,KEY=VALUE] busybox

Functions

When you create and run a container, use the –mount option to mount the files, directories, or volumes on the host to the container for data persistence.

Parameter Description

  • type: Type of data mounted to the container. The value can be bind, volume, or squashfs. If this parameter is not specified, the default value is volume.
  • src: Path of the file, directory, or volume to be mounted on the host. If the value is an absolute path, the file or directory on the host is mounted. If the value is a volume name, a volume is mounted. If this parameter is not specified, the volume is an anonymous volume. If a folder or volume does not exist, iSula creates a file or volume and then mounts it. The keyword src is also called source.
  • dst: Mount path in the container. The value must be an absolute path. The keyword dst is also called destination or target.
  • KEY=VALUE: Parameter of –mount. The values are as follows:
KEYVALUE
selinux-opts/bind-selinux-optsz or Z. z indicates that if SELinux is enabled, the SELinux share label is added during mounting. Z indicates that if SELinux is enabled, the SELinux private label is added during mounting.
ro/readonly0/false indicates that the mount is read/write. 1/true indicates that the mount is read-only. If this parameter is not specified, the mount is read-only. The parameter is supported only when type is set to bind.
volume-nocopyData at the mount point is not copied. If this parameter is not specified, data is copied by default. In addition, if data already exists in the volume, the data will not be copied. This parameter is supported only when type is set to volume.

Examples

Run the container based on BusyBox, create or mount a volume named vol to the /vol directory of the container, and set the mount point to read-only. In addition, if data exists at the mount point in the container, the data is not copied.

isula run --mount type=volume,src=vol,dst=/vol,ro=true,volume-nocopy=true busybox

Reusing the Mounting Configuration in Other Containers

Format

isula run --volumes-from CON1[:MODE] busybox

Functions

When you create and run a container, use the –volumes-from option to indicate that the mount point configuration includes that of the CON1 container. You can set multiple –volumes-from options.

Parameter Description

  • CON1: Name or ID of the container whose mount point is reused.
  • MODE: If the value is ro, the mount point is read-only. If the value is rw, the mount point is read/write.

Examples

Assume that a container named container1 has been configured with a volume vol1 to the container directory /vol1, and a container named container2 has been configured with a volume vol2 to the container directory /vol2. Run a new container to reuse the mounting configuration of container1 and container2. That is, volume vol1 is mounted to the /vol1 directory of the container, and volume vol2 is mounted to the /vol2 directory of the container.

isula run --volumes-from container1 --volumes-from container2 busbyox

Using the Anonymous Volume in an Image

You do not need to perform any configuration to use the anonymous volume in the image. If an anonymous volume is configured in the image, iSula automatically creates an anonymous volume and mounts it to the specified path in the image at container runtime. You can write data to the mount point of an anonymous volume in a container for data persistence.

Querying a Volume

Format

isula volume ls [OPTIONS]

Functions

This command is used to query all volumes managed by iSula.

Parameter Description

Option:

  • -q,–quit: If this parameter is not specified, only the volume driver information and volume name are queried by default. If this parameter is specified, only the volume name is queried.

Examples

This command is used to query all volumes managed by iSula and return only the volume name.

isula volume ls -q

Deleting a Volume

Format

isula volume rm [OPTIONS] VOLUME [VOLUME...]
isula volume prune [OPTIONS]

Functions

  • rm: deletes a specified volume. If the volume is used by a container, the volume fails to be deleted.
  • prune: deletes all volumes that are not used by containers.

Parameter Description

OPTIONS in the prune command:

  • -f,–force: specifies that the system does not display a message asking you whether to delete the volume. By default, a risk message is displayed. You need to enter y to continue the operation.

Examples

Delete volumes vol1 and vol2.

isula volume rm vol1 vol2

Delete all unused volumes in the following format. No risk message is displayed.

isula volume prune -f

Precautions

Conflict Combination Rules

If a volume mount point conflict occurs, perform the following operations:

  • If configurations of -v and –mount conflict, a failure message is returned.
  • If the configuration obtained from –volumes-from conflicts with the -v or –mount configuration, the configuration is discarded.
  • If the anonymous volume configuration in the image conflicts with the -v, –mount, or –volumes-from configuration, the configuration is discarded.

Differences Between iSula and Docker

iSula BehaviorDocker Behavior
The volume name can contain a maximum of 64 characters.The length of the volume name is not limited.
If the source to be mounted does not exist, the –mount parameter is created.If the source to be mounted does not exist, an error is reported.
The –mount parameter supports the z or Z parameter configuration in bind-selinux-opts and selinux-opts.The –mount parameter does not support the parameter configuration in the bind-selinux-opts and selinux-opts.
Rules for combining mount point conflicts are not processed.The anonymous volume specified by -v is processed as the anonymous volume in the image.
The volume prune command displays the space that has been reclaimed.The volume prune command does not display the space that has been reclaimed.
-v, –mount, and –volumes-from are configured in hostconfig, and the anonymous volume is configured in config.The anonymous volume specified by -v is configured in config, and other configurations are configured in hostconfig.

有奖捉虫

“有虫”文档片段

存在的问题

提交类型 issue
有点复杂...
找人问问吧。
PR
小问题,全程线上修改...
一键搞定!
问题类型
规范和低错类

● 错别字或拼写错误;标点符号使用错误;

● 链接错误、空单元格、格式错误;

● 英文中包含中文字符;

● 界面和描述不一致,但不影响操作;

● 表述不通顺,但不影响理解;

● 版本号不匹配:如软件包名称、界面版本号;

易用性

● 关键步骤错误或缺失,无法指导用户完成任务;

● 缺少必要的前提条件、注意事项等;

● 图形、表格、文字等晦涩难懂;

● 逻辑不清晰,该分类、分项、分步骤的没有给出;

正确性

● 技术原理、功能、规格等描述和软件不一致,存在错误;

● 原理图、架构图等存在错误;

● 命令、命令参数等错误;

● 代码片段错误;

● 命令无法完成对应功能;

● 界面错误,无法指导操作;

风险提示

● 对重要数据或系统存在风险的操作,缺少安全提示;

内容合规

● 违反法律法规,涉及政治、领土主权等敏感词;

● 内容侵权;

您对文档的总体满意度

非常不满意
非常满意
创Issue赢奖品
根据您的反馈,会自动生成issue模板。您只需点击按钮,创建issue即可。