Reputation: 573
I am very new to docker, and for a project which uses a web app I am looking into using it.
I have set up a dockerfile
which creates a CentOS image with Tomcat and Apache installed.
I am confused if I should include my source code of the web app so that it will be included in the image, or if I should mount in using the -v
command when I run the container?
The way I am looking at it is I think it would be easier to mount it when I run, as I could checkout my code from SVN, stop the container, redeploy (not sure if these two are needed?), and it would be updated. If I were to include the source in the image, I would have to checkout the code, rebuild the image, stop the container, and then redeploy the new one - adding atleast one extra step.
Are there any advanatges/disadvantages of using one over the other?
Upvotes: 2
Views: 180
Reputation: 43235
A good approach would be to not have it as a part of the container. This will give you more flexibility of maintaining your container and the code.
Suggestions:
The container image whenever deployed will do a latest checkout from SVN/Git ( or whatever versioning tool you use) and load that application code.
You can keep committing your code changes to SVN, the container will always have newest code whenever run.
You can distribute your images without having to worry about secrets or keys embedded into the container. That security can be well administrated by properly using your SVN.
This also allows you to use the same container as development environment, by mounting your codebase ( with development specific environment settings), and running it on the docker image, and then committing your changes to your SVN repo.
Upvotes: 3