'How to pass environment variable in docker-compose command from the terminal
In docker we can pass environment variable as docker run -e -e "TEST_SUITE=TNT-TestSuite.xml".
Can I do the same or similar for the docker-compose? Right now I had to define this kind envirment varible into the docker-compose.yml file. But I want to pass it when I run the command as docker-compose -e "TEST_SUITE=TNT-TestSuite.xml" up or something similar? Please let me know.
Solution 1:[1]
I am doing it in this way:
Docker-compose part:
some-app:
...
environment:
- ENV_VAR_1=${ENV_VAR_1}
- ENV_VAR_1=${ENV_VAR_2}
command: some command
And then command:
ENV_VAR_1="value1" ENV_VAR_2="value2" docker-compose -f ./docker/docker-compose.yml (path to docker-compose file) run some-app
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
| Solution | Source |
|---|---|
| Solution 1 | IvanMikhalka |
