There is another way to start a container with a volume from another container:
Take a look at https://docs.docker.com/userguide/dockervolumes/
Creating and installing a data volume container
If you have persistent data that you want to share between containers or want to use from mutable containers, it is best to create a named container for the data volume and then mount the data from it.
Create a new named container with shared volume.
$ sudo docker run -d -v /dbdata --name dbdata training/postgres echo Data-only container for postgres
Then you can use the --volumes-from flag to mount the / dbdata volume in another container.
$ sudo docker run -d --volumes-from dbdata --name db1 training/postgres
And further:
$ sudo docker run -d --volumes-from dbdata --name db2 training/postgres
Another useful feature that we can perform with volumes is to use them for backup, recovery, or migration. We do this using the --volumes-from flag to create a new container that mounts this volume, for example:
$ sudo docker run --volumes-from dbdata -v $(pwd):/backup ubuntu tar cvf /backup/backup.tar /dbdata
==============
I think you should not use setting your host directory in a container. But you can use volumes with all its capabilities. You can edit files in volumes using other containers with the perfect mix of your editors and tools. And the container that your application will be clean without overhead.
Structure:
-) Container for application data
docker run -d -v /data --name data
-) Container for binary application files
docker run -d --volumes-from data --name app1
-) Container for editors and development tools
docker run -d --volumes-from data --name editor
Mikl Nov 13 '14 at 18:31 2014-11-13 18:31
source share