0

I've noticed that docker-compose run has command-line input argument functionality with the -e flag, where running

docker-compose run -e ARG1="val1" -e ARG2="val2"

is valid. I'm however using docker-compose up, where the flag is not included. I've found a way to include a single variable:

ARG1="val1" docker-compose up

but how do I add multiple? I've tried separating by comma, semicolon, and others, but there seems to be no way to pass more than one command line argument to docker-compose. I also understand that I can add multiple such values into an .env file, but input in the command line is much more convenient for my use case. Any suggestions?

1 Answer 1

2

The syntax:

VAR=value command ...

Isn't specific to docker-compose; that's just normal shell syntax (for setting temporary environment variables that are only visible to the specified command).

You can add as many variables as you want:

ARG1="val1" ARG2="val2" ARG3="val3" docker-compose up

These only make sense if your docker-compose.yaml references the specific variables.


A better option be to use environment files. You can use the --env-file option to docker-compose to select different environment files, so you can do something like:

docker-compose --env-file config1.env up

Or

docker-compose --env-file config2.env up
Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.