0 0 Share PDF

What does the 'Reuse existing container volumes?' option mean during stack redeployment in Docker Cloud?

Article ID: KB000476

Question

What does the "Reuse existing container volumes?" option mean during stack redeployment in Docker Cloud?

Answer

There are two types of volumes that you can mount on a container which are:

  • Data volumes
  • Data volume containers

Data volumes are volumes which are mounted from the host itself whereas data volume containers mount the volume(s) from a volume container (e.g. busybox container). Take note that you would need to use the volume_fromkey instead of the usual volumekey in order to use data volume containers' volume(s).

For more information on this, please refer to the documentation provided in the link below:

https://docs.docker.com/docker-cloud…rence/#volumes

Take the below Stackfile as an example:

test-busybox:
  image: 'busybox:latest'
  command: /bin/echo
  restart: always
  roles:
    - global
  volumes:
    - /var/lib/mysql

test-mysql:
  image: 'tutum/mysql:latest'
  environment:
    - MYSQL_PASS=admin
    - MYSQL_USER=admin
  expose:
    - '3306'
  restart: always
  roles:
    - global
  volumes_from:
    - test-busybox

The test-mysqlMySQL container will always use the /var/lib/mysqlvolume mounted on the test-busyboxBusybox container. If the "Reuse existing container volumes?" option is set to ‘No’ during stack redeployment, the volume on the test-busyboxcontainer will be reset and all data on /var/lib/mysqlwill be gone.

You can also replicate this if you use the following Stackfile:

test-mysql:
  image: 'tutum/mysql:latest'
  environment:
    - MYSQL_PASS=admin
    - MYSQL_USER=admin
  expose:
    - '3306'
  restart: always
  roles:
    - global
  volumes:
    - /var/lib/mysql