We are trying to create a Docker container which will host and run our webapp (mainly written in PHP with Symfony2).

For the moment, the container embeds all the application code, cloned when building the image (through a Dockerfile). The app runs correctly, on OSX, through Vagrant (Precise64 base image). We are now struggling to share the container embedded code with the host (Vagrant -> OSX) for development purpose (edit a file on the host OSX should affect the container code). Seems that there is no way to share this folder from container to the host. Sharing a folder from host to container (-v option of the run command) overwrites the original container folder. A soft link does not work as well since the hosts (Vagrant and OSX) could not read the original location.

I'm sure that the solution is with the Docker's volumes (http://docs.docker.io/en/latest/use/working_with_volumes/) but we have not figured out yet how to make it works.

Do you have feedback / experience on it ?

有帮助吗?

解决方案

You can share your file in OSX to container in the following line:

OSX dir(host) -shared fold-> /vagrant(vagrant) -volume-> container dir(container)

but the the file is saved in you host not container.

If you want save the file in container and share it to your OSX host, all your container file is in a aufs dir in /var/lib/docker/aufs/mnt/{container id}, your can share this fold to you OSX by the feather supported by vagrant or others:

container dir(container) -aufs-> /var/lib/docker/aufs/mnt/{id}(vagrant) -some-> OSX dir(host)
许可以下: CC-BY-SA归因
不隶属于 StackOverflow
scroll top