Reputation: 578
Is there a tool to dynamically set services
, external_links
, etc. for container orchestration, depending on an environment variable?
Tool should have convenient syntax (Python/js/bash - any clearly readable), and support conditions (if).
Now I have 3 files like docker-compose.local.yml
, and edit them all.
cp docker-compose.local.yml docker-compose.yml;
docker-compose up;
I wan't one config file
ENV=local;
docker-compose up; # or "node start-compose.js"
I know that docker-compose supports environment variables like
volumes:
- ${ENV}-filename:/.../filename
But I need more.
Upvotes: 2
Views: 2236
Reputation: 2584
You can use .env
files to store all your compose configuration.
Just as you do cp docker-compose.local.yml docker-compose.yml;
You do cp local.env .env;
docker-compose up
will automatically pick up the .env
file.
Taken from the docs Environment Variables in Compose
Upvotes: 1