I have a docker-compose based application which I am deploying to production server. Two of its containers share a directories contents using a data volume like so:
...
services:
service1:
volumes:
- server-files:/var/www
service2:
volumes:
- server-files:/var/www
db:
volumes:
- db-persistent:/var/lib/mysql
volumes:
server-files:
db-persistent:
The service1's /var/www is populated when its Dockerfile is built.
My understanding is that if I make changes to code stored in /var/ww when I rebuild service1
its updates will be hidden by the existing server-files volume.
What is the correct way to update this deployment so that changes propagate with minimal downtime and without deleting other volumes?
Edit
Just to clarify my current deploy process works as follows:
- Update code locally and and commit/push changes to Github
- Pull changes on server
- Run
docker-compose buildto rebuild any changed containers - Run
docker-compose up -dto reload any updated containers
The issue is that changed code within /var/www is hidden by the already existing named volume server-files. My question is what is the best way to handle this update?