Issue
I'm setting up a new docker-based server and I'm writing a script to run
$ docker-compose
for all my docker-compose.yml
files at once.
I know about existence of .env
files and I know about env_file
option in docker-compose.yml
, however the .env
files are ignored when I launch
$ docker-compose up
from other directory and not even full path in env_file
helps.
my_script.sh:
#!/bin/bash
docker-compose up -f /server1/docker-compose.yml -f /server2/docker-compose.yml -f /server3/docker-compose.yml
Docker-compose.yml:
version: '3'
services:
service_name:
build: /server1/apache
env_file: /server1/.env
volumes:
- /web/${ROOT_DOMAIN}/web/:/var/www/:rw
.env
ROOT_DOMAIN=server1.domain.tld
I want to replace the ${ROOT_DOMAIN}
variable in volumes for the variable defined in .env
file. This works like a charm, when I run
$ docker-compose up
from the /server1/
folder. However when I run my script, which is in other directory, the enviroment variables are ignored and default to null.
How to fix this?
Solution
Sorry to say, but this cannot be fixed. The provided .env
file must be in the same directory.
This is a requirement of docker compose and is described in the docs (first paragraph): https://docs.docker.com/compose/env-file/
Answered By - mbuechmann Answer Checked By - Pedro (PHPFixing Volunteer)
0 Comments:
Post a Comment
Note: Only a member of this blog may post a comment.