Declaring default environment variables in docker-compose.

0 votes
How to declare default environment variables under docker-compose?
Jul 3 in Docker by Ruby
9 views

1 answer to this question.

0 votes

Compose supports declaring default environment variables in an environment file named .env placed in the folder where the docker-compose command is executed (current working directory).

Example: The below example demonstrate how to declare default environmental variable for Docker Compose.

$ cat .env
TAG=v1.5

$ cat docker-compose.yml
version: '3'
services:
  web:
    image: "webapp:${TAG}"

When you run docker-compose up, the web service defined above uses the image webapp:v1.5. You can verify this with the `docker-compose config` command which prints your resolved application config to the terminal.

$ docker-compose config

version: '3'
services:
  web:
    image: 'webapp:v1.5'
answered Jul 3 by Sirajul
• 5,960 points

Related Questions In Docker

0 votes
1 answer

How do I pass environment variables to Docker containers?

You can pass environment variables to your ...READ MORE

answered Jul 20, 2018 in Docker by Kalgi
• 37,320 points
46 views
+1 vote
4 answers

Docker compose, running containers in net:host

Hey@Hannah, Check the compose file format specifications ...READ MORE

answered May 7 in Docker by Kishore
1,298 views
0 votes
1 answer

docker set iptables options in docker-compose.yml

The --iptables option only applies to the ...READ MORE

answered Aug 2, 2018 in Docker by Kalgi
• 37,320 points
264 views
0 votes
1 answer
0 votes
1 answer
0 votes
1 answer

Deploy Docker Containers from Docker Cloud

To solve this problem, I followed advice ...READ MORE

answered Sep 3, 2018 in AWS by Priyaj
• 56,160 points
99 views
0 votes
1 answer
0 votes
1 answer

Can I run docker-compose inside a container?

Compose can also be run inside a ...READ MORE

answered Jun 10 in Docker by Sirajul
• 5,960 points
52 views