Reputation: 133
So i learned that you can use the same docker-compose file for both local development with docker-machine and for production environment with docker swarm, which is great think, you can also share the same docker-compose file and add specific configuration for production/local enviroment.
One think i couldnt find is a way to define a service only on local enviroment, i have compose file locally which contain redis/node/nginx/mongo containers BUT in production i dont want to use docker for mongo since i use external server(Atlas/ MLab), is it possible to do so and keep using the same files for production & development ?
Upvotes: 1
Views: 112
Reputation: 51876
Docker compose has a solution for the different environment compose files Multiple Compose files. You basically extract the differences into a sub compose file and when running you can merge the compose files:
docker-compose.yml
version: '3'
services:
redis:
...
node:
...
nginx:
...
docker-compose.local.yml
...
services:
mongo:
...
When running locally you execute:
docker-compose -f docker-compose.yml -f docker-compose.local.yml up -d
And when deploying to Swarm you just execute:
docker stack deploy --compose-file docker-compose.yml
Upvotes: 1