Use data volume containers using host mounted paths as recommended by Docker. What you do here is suggesting users to run a data container using container FS path. IE users will lose their data if they destroy the data container.
Pasting in the suggested procedure from Docker:
Creating and mounting a data volume container
If you have some persistent data that you want to share between containers, or want to use from non-persistent containers, it’s best to create a named Data Volume Container, and then to mount the data from it.
Let’s create a new named container with a volume to share. While this container doesn’t run an application, it reuses the training/postgres image so that all containers are using layers in common, saving disk space.
$ docker create -v /dbdata --name dbstore training/postgres /bin/true
You can then use the --volumes-from flag to mount the /dbdata volume in another container.
$ docker run -d --volumes-from dbstore --name db1 training/postgres
Use data volume containers using host mounted paths as recommended by Docker. What you do here is suggesting users to run a data container using container FS path. IE users will lose their data if they destroy the data container.
Pasting in the suggested procedure from Docker:
Creating and mounting a data volume container
If you have some persistent data that you want to share between containers, or want to use from non-persistent containers, it’s best to create a named Data Volume Container, and then to mount the data from it.
Let’s create a new named container with a volume to share. While this container doesn’t run an application, it reuses the training/postgres image so that all containers are using layers in common, saving disk space.
$ docker create -v /dbdata --name dbstore training/postgres /bin/true You can then use the --volumes-from flag to mount the /dbdata volume in another container.
$ docker run -d --volumes-from dbstore --name db1 training/postgres