Hi,
I want to attach a directory from the host /home/guest/app on a Docker container, but this container make changes on this volumes, and I don’t want this changes reflected on the host.
$ docker run -d --name webserver01 -v /home/guest/app:/app
Don’t believe that is possible with volumes. If you need the content to begin with but don’t need changes persisted then maybe you can tar the folder and move it to your build context before creating the image (so you can ADD or COPY it in via the Dockerfile)? Or you can do a docker cp after the container has been created.
Yes, you need to make sure the files you need are in the context of the build. So either you make the context /home/guest/ and make sure you add anything you don’t want to be added to your .dockerignore file. Or you can just zip up that directory and put it inside your current build context before doing the build (then you would be able to COPY it).
Are you storing the Dockerfile for this app outside of the app directory? Might be a good idea to keep everything for the app in one directory, or at least keep the Dockerfile in a subdirectory of the app directory? Would probably make your building experience easier.
The problem here is, this app (/home/guest/app) is in Github, and is web-app, the core of a CMS.
I have a lot of this web-sites with the same web-app, my idea is, uses the same files for the core and make the changes necesarry inside the container to each web-site.
And if I made some changes on the web-app, some bug fixes, improvements, etc, this changes are reflected on each Docker container.
I need to think more this solution, I hope do you understand, my english is not so good.
Wouldn’t you want each website’s changes to be recorded somewhere though? Rather than just existing inside the transient container? Can you post a representation of your filesystem organisation and what needs to go where?
Sounds like your setup may benefit from some refactoring.