Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

docker compose variable substitution

It seems that I am not understanding something about variable substitution in the following page (my variable NUM is not registering): https://github.com/compose-spec/compose-spec/blob/master/spec.md#Interpolation

See screenshot below. Running this on mac OSX.

docker-compose up

like image 421
user3659451 Avatar asked Dec 22 '15 01:12

user3659451


People also ask

Can you use variables in docker compose file?

We can also specify variables in the docker-compose file that get filled in with values from the . env file. Check out this example: we want our container to have a label that's specified in the . env file.

How do I pass environment variables to docker containers?

Using –env, -e When we launch our Docker container, we can pass environment variables as key-value pairs directly into the command line using the parameter –env (or its short form -e). As can be seen, the Docker container correctly interprets the variable VARIABLE1.

What is Depends_on in docker compose?

depends_on is a Docker Compose keyword to set the order in which services must start and stop. For example, suppose we want our web application, which we'll build as a web-app image, to start after our Postgres container.

Does docker use .env file?

Here's a list of easy takeaways: The . env file, is only used during a pre-processing step when working with docker-compose. yml files.


1 Answers

Regarding docker-compose variable substitution, it can depend on how NUM has been set.
set NUM=5 would only set it in the current shell, not for another process.
Make sure to type:

export NUM=5
like image 92
VonC Avatar answered Sep 21 '22 00:09

VonC