edit-icon download-icon

Use third-party data volumes

Last Updated: Feb 13, 2018

Third-party data volumes are used in the same way as local data volumes.

You can set the data volumes when creating an application or changing the configurations of an existing application.

Prerequisites

You have created a data volume in Container Service console. For more information, see Create an OSSFS data volume, Create an NAS data volume, and Create cloud disk data volumes.

Procedure

Take the OSSFS data volume ossvol in the swarm-mode cluster as an example.

1

Create an application by using an image

  1. Log on to the Container Service console.

  2. Click Applications under Swarm in the left-side navigation pane.

  3. Click Create Application in the upper-right corner.

  4. Enter the basic information for the application you want to create and then click Create with Image. In this example, enter volume as the Name and select swarm-mode as the Cluster.

    Note: The cluster on which the application will be deployed must be the same as the one of the OSSFS data volume that you want to use.

    1

  5. Select the image you want to use and complete the other configurations.

    Note: For how to create an application by using an image, see Create an application.

  6. Click the plus icon in the Data Volume section. Enter the data volume name in the Host Path or Data Volume Name field. Enter the Container Path and select RW or RO as the data volume permission.

    2

  7. Click Create at the right of the page after completing the settings.

  8. On the Data Volume List page, you can see that the OSSFS data volume ossvol is referenced by the container of the volume application.

Create an application by using an orchestration template

  1. Log on to the Container Service console.

  2. Click Applications under Swarm in the left-side navigation pane.

  3. Click Create Application in the upper-right corner.

  4. Enter the basic information for the application you want to create and then click Create with Orchestration Template. In this example, enter volume as the Name and select swarm-mode as the Cluster.

    Note: The cluster on which the application will be deployed must be the same as the one of the OSSFS data volume that you want to use.

    1

  5. Click Use Existing Orchestration Template or use your own orchestration template.

    Note: For how to create an application by using an orchestration template, see Create an application.

  6. In the volumes section of the template, enter the data volume name, container path, and permission.

    Compose V1/V2 sample:

    1. volume:
    2. image: wordpress:4.5
    3. ports:
    4. - '80'
    5. restart: always
    6. labels:
    7. aliyun.logs: /var/log
    8. aliyun.probe.url: http://container/license.txt
    9. aliyun.probe.initial_delay_seconds: '10'
    10. aliyun.routing.port_80: http://wordpress
    11. aliyun.scale: '3'
    12. volumes:
    13. - 'ossvol:/swarmmode:rw'

    Compose V3 sample:

    1. version: '3.2'
    2. services:
    3. volume:
    4. image: wordpress
    5. deploy:
    6. mode: replicated
    7. replicas: 1
    8. update_config:
    9. failure_action: continue
    10. restart_policy:
    11. condition: any
    12. volumes:
    13. - 'ossvol:/swarmmode:rw'
    14. volumes: #Declare your data volume
    15. ossvol:
    16. external: true

    In Compose V3, you must declare the data volume to be used by the application. Otherwise, an error is reported during the application deployment. external: true indicates the data volume has been created, Container Service will not try to create the data volume when creating an application, but will search for the data volume and mount the data volume to the container.

  7. Click Create and Deploy after completing the settings.

  8. On the Data Volume List page, you can see that the OSSFS data volume ossvol is referenced by the container of the volume application.

Change the configurations of an existing application

  1. Log on to the Container Service console.

  2. Click Applications under Swarm in the left-side navigation pane.

  3. Select the cluster (the swarm-mode cluster in this example) in which the application resides from the Cluster list.

  4. Click Update next to the application you want to change the configurations.

    For how to change the application configurations, see Change application configurations.

    Note: Make sure the application and the OSSFS data volume you want to use are in the same cluster.

  5. The Change Configuration dialog box appears. In the volumes section of the template, enter the data volume name, container path, and permission.

    Compose V1/V2 sample:

    1. volume:
    2. image: wordpress:4.5
    3. ports:
    4. - '80'
    5. restart: always
    6. labels:
    7. aliyun.logs: /var/log
    8. aliyun.probe.url: http://container/license.txt
    9. aliyun.probe.initial_delay_seconds: '10'
    10. aliyun.routing.port_80: http://wordpress
    11. aliyun.scale: '3'
    12. volumes:
    13. - 'ossvol:/swarmmode:rw'

    Compose V3 sample:

    1. version: '3.2'
    2. services:
    3. volume:
    4. image: wordpress
    5. deploy:
    6. mode: replicated
    7. replicas: 1
    8. update_config:
    9. failure_action: continue
    10. restart_policy:
    11. condition: any
    12. volumes:
    13. - 'ossvol:/swarmmode:rw'
    14. volumes: #Declare your data volume
    15. ossvol:
    16. external: true

    In Compose V3, you must declare the data volume to be used by the application. Otherwise, an error is reported during the application deployment. external: true indicates the data volume has been created, Container Service will not try to create the data volume when creating an application, but will search for the data volume and mount the data volume to the container.

  6. Click OK after completing the modifications.

  7. On the Data Volume List page, you can see that the OSSFS data volume ossvol is referenced by the container of the volume application.

Thank you! We've received your feedback.