1

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.

2
  • 2
    Like this ? Commented Apr 22, 2022 at 9:42
  • You can pass a value at runtime but you'd still need to define the variable in the env -> docs.docker.com/compose/environment-variables As for example in the environment section of the docker compose you should add the definition for TEST_SUITE=${TEST_SUITE} and then at runtime you can add the variable in the docker-compose run Commented Apr 22, 2022 at 10:48

1 Answer 1

3

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
Sign up to request clarification or add additional context in comments.

Comments

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.