Embed code in docker container or mount it as a volume?

与世无争的帅哥 提交于 2019-12-07 11:47:20

问题


I'm a recent user of docker and I am about to migrate from VM to containers in my production environment. But then, I suddenly realize that what works perfectly for my dev and qa environments is not ideal for production.

On my dev and qa, I mount my versioned project folder into a python/php (name it) container and I consider this container as a "running service" for my code. This saves me from having huge containers as the container history doesnt change when I change my code (git commit or else).

In production, the ideal case is that I will have clean self contained containers with my code inside, not mounted like I do in dev.

So, did I get it wrong? How do you do it? Do you use the same containers from dev to prod?


回答1:


I do the same for in my development environment. I have a production Dockerfile that ADDs the project folder and then I run all the tests against it. Since the only difference between the development container and the production container is when the code is added to the container, not the code or settings, they have the same behavior.




回答2:


indeed you can do this by add an additional arguments called -v when you run it

sudo docker run -i -t -v /home/ubuntu/my_code:/home/mydocker/my_code ubuntu/my_docker /bin/bash



来源:https://stackoverflow.com/questions/25497305/embed-code-in-docker-container-or-mount-it-as-a-volume

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!