Declaring default environment variables in docker-compose

0 votes
How to declare default environment variables under docker-compose?
Jul 3, 2019 in Docker by Ruby
2,564 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, 2019 by Sirajul
• 59,230 points

Related Questions In Docker

+1 vote
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
• 52,350 points
1,704 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, 2019 in Docker by Kishore
5,430 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
• 52,350 points
2,443 views
0 votes
1 answer

Efficient way to run a Docker Compose stack in production?

Here is a concept which you can ...READ MORE

answered Aug 2, 2018 in Docker by Damon Salvatore
• 5,980 points
1,163 views
+2 votes
1 answer
+2 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
• 58,020 points
2,739 views
0 votes
1 answer
0 votes
2 answers

How do I fix the “no space left on device” error in docker?

Try cleaning up: $ docker volume rm $(docker ...READ MORE

answered Aug 14, 2019 in Docker by Sirajul
• 59,230 points
12,707 views
webinar REGISTER FOR FREE WEBINAR X
REGISTER NOW
webinar_success Thank you for registering Join Edureka Meetup community for 100+ Free Webinars each month JOIN MEETUP GROUP