Declaring default environment variables in docker-compose.

0 votes
How to declare default environment variables under docker-compose?
Jul 3 in Docker by Ruby
272 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
• 38,820 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
• 42,510 points
86 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,676 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
• 42,510 points
355 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,940 points
228 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 in Docker by Sirajul
• 38,820 points
2,116 views