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.
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.
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.
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.
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.
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
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With