user3214546
user3214546

Reputation: 6831

Should the docker production image needs code as volume or not

I am using docker and I mount my code in /var/www/code in host in my development.

Now when I want to release my stuff in production I have two doubts

  1. Do I follow the same process and update the code in production host with deployment script
  2. Or my production image does not have any host mounted volumes and even I put my code as part of image so that in production I don't need to grab any code from github.

I am not sure which way to go

Upvotes: 2

Views: 578

Answers (1)

Usman Ismail
Usman Ismail

Reputation: 18679

Both are valid ways of doing things. If you use kubernetes, Amazon Container service etc you probably have to use option 2 as they do not support host mounted volumes. Option 2 is also more portable as you can move containers around on a multi-node docker swarm easily. However, if you already have a deployment system setup using chef or cloud-formation etc option 1 does allow for more generic containers which are not tied to versions of your code.

Volumes themselves can never be part of the image as they are always mounted from hosts. However, you can make a generic base image and then have docker file in your code repo with

from my-user/my-generic-base
ADD /code:/var/www/code

When you deploy your downstream container to dockerhub make sure you deploy it with a version number which indicates the code version it will run.

Upvotes: 1

Related Questions