Skip to main content

Docker Success Center

The Docker enterprise customer portal.

Docker, Inc.

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

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_from key instead of the usual volume key 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-mysql MySQL container will always use the /var/lib/mysql volume mounted on the test-busybox Busybox container. If the "Reuse existing container volumes?" option is set to ‘No’ during stack redeployment, the volume on the test-busybox container will be reset and all data on /var/lib/mysql will 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
  • Was this article helpful?