Container Volumes

CLI Tutorial: Container Volumes

Container volumes provide persistent local storage that remains available through common container lifecycle operations. They help preserve important application data and improve data integrity.

Container volumes can be configured through environment topology settings or managed separately with direct CLI methods.

Volume Configuration Methods

Environment Topology Define volumes while creating an environment or changing its topology.
Direct CLI Methods Add or remove volumes without changing the rest of the environment topology.

The topology-based method uses the following parameters inside the appropriate docker section:

  • volumes — defines local container volumes.
  • volumeMounts — configures mount points.
  • volumesFrom — imports existing volumes from another node.
These parameters can also be used in JPS application manifests.

Define Local Volumes

Declare one or more persistent local-volume paths inside the Docker configuration:

... "docker": {
  ...
  "volumes": [
    "{local_volume}",
    "{local_volume}"
  ]
}

Replace {local_volume} with the path where the volume should be created inside the container. Multiple volume paths can be supplied in the same list.

Example: An environment can contain local volumes such as /my_volume_1 and /my_volume_2.

Configure Volume Mounts

Use volumeMounts to make data from another node or storage host available at a local path:

... "docker": {
  ...
  "volumeMounts": {
    "{local_path}": {
      "sourcePath": "{remote_path}",
      "sourceNodeId": "{node_ID}",
      "readOnly": {true/false}
    }
  }
}
ParameterDescription
{local_path}Folder path on the client node where the mounted content should appear.
{remote_path}Directory path on the remote source container.
{node_ID}Unique identifier of the source node.
{true/false}Defines read-only or read/write access. The default is false.

Instead of sourceNodeId, the source can also be selected with:

  • sourceNodeGroup — uses the master node of the specified environment layer.
  • sourceHost — uses the external IP address or custom domain of a storage server, including an external server.

Import Volumes from Another Node

Use volumesFrom to mount existing volumes from another node:

... "docker": {
  ...
  "volumesFrom": [
    {
      "sourceNodeId": "{node_ID}",
      "readOnly": {true/false},
      "volumes": [
        "{local_volume}",
        "{local_volume}"
      ]
    }
  ]
}
  • sourceNodeId identifies the node containing the source volumes.
  • sourceNodeGroup can be used instead to select the master node of a layer.
  • readOnly controls read-only or read/write access and defaults to false.
  • volumes lists the volumes to mount. If omitted, all available volumes are imported.

Direct Volume Management

The following CLI methods manage volumes without changing the remaining environment topology.

Add a Volume to One Container

~/jelastic/environment/control/addcontainervolume \
  --envName {env_name} \
  --nodeId {node_ID} \
  --path {path}

Remove a Volume from One Container

~/jelastic/environment/control/removecontainervolume \
  --envName {env_name} \
  --nodeId {node_ID} \
  --path {path}

Add a Volume to an Entire Layer

~/jelastic/environment/control/addcontainervolumebygroup \
  --envName {env_name} \
  --nodeGroup {node_group} \
  --path {path}

Remove a Volume from an Entire Layer

~/jelastic/environment/control/removecontainervolumebygroup \
  --envName {env_name} \
  --nodeGroup {node_group} \
  --path {path}

CLI Parameters

ParameterDescription
{env_name}Name of the environment that should be modified.
{node_ID}Unique identifier of the individual container.
{node_group}Environment-layer identifier such as cp, bl, or storage.
{path}Local filesystem path of the volume directory.
Removal warning: Confirm that important data is backed up or no longer required before removing a persistent volume.

What’s next?