How do you create a Docker Compose file that is parametrized using environment variables?

Experience Level: Junior
Tags: Docker Compose

Answer

To write an environment variable value to a Docker Compose file, use the ${ENVIRONMENT_VARIABLE_NAME} syntax.
If the environment variable exists, the placeholder will be replaced by the value of the environment variable when the Docker Compose file is used.

version: "3.4"
services:
  my-service:
    image: "webapp:${TAG}"

Note that the environment variables must reside in a file .env or other file that is passed to docker using --env-file parameter.

Comments

No Comments Yet.
Be the first to tell us what you think.
Docker Compose
Docker Compose

Are you learning Docker Compose ? Try our test we designed to help you progress faster.

Test yourself

Chat

Oh, the operator is not available. Leave us your comments. We will answer all your questions as soon as possible.

Comments

Anonymous
Καλησπέρα.
Anonymous
the infinteis -3/15 so 1triition / infinet
Anonymous
e
Anonymous
<a href="https://inspirum.pl "
Anonymous
[url]https://inspirum.pl[/url]
LaceJaguar65
e
LaceJaguar65
e
LaceJaguar65
e
LaceJaguar65
e
LaceJaguar65
e
LaceJaguar65
e
LaceJaguar65
e
LaceJaguar65
e
LaceJaguar65
e
LaceJaguar65
e
LaceJaguar65
e
LaceJaguar65
e
LaceJaguar65
e
LaceJaguar65
e
LaceJaguar65
e
LaceJaguar65
e
LaceJaguar65
e
LaceJaguar65
e
LaceJaguar65
e
LaceJaguar65
e