Is it possible to have a shared .env file? #11327
Unanswered
shimizurei
asked this question in
Q&A
Replies: 1 comment 2 replies
-
Can you be more specific on what the error you're getting is? Trying this out in Compose seems to work just fine. Given file version: "3.8"
services:
serviceA:
image: ubuntu
env_file:
- ../.env
- serviceA.env
command: env
serviceB:
image: ubuntu
env_file:
- serviceB.env
- ../.env
command: env And environment files # .env
TEST_VARIABLE=test
# serviceA.env
SERVICE_NAME=serviceA
# serviceB.env
SERVICE_NAME=serviceB And running [+] Running 2/2
- Container docker_serviceA_1 Started 1.0s
- Container docker_serviceB_1 Started 1.0s
Attaching to serviceA_1, serviceB_1
serviceB_1 | PATH=/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin
serviceB_1 | HOSTNAME=796e678cbaf8
serviceB_1 | SERVICE_NAME=serviceB
serviceB_1 | TEST_VARIABLE=test
serviceB_1 | HOME=/root
serviceA_1 | PATH=/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin
serviceA_1 | HOSTNAME=a215ba7495af
serviceA_1 | TEST_VARIABLE=test
serviceA_1 | SERVICE_NAME=serviceA
serviceA_1 | HOME=/root
serviceB_1 exited with code 0
serviceA_1 exited with code 0 Which seems to be correct. |
Beta Was this translation helpful? Give feedback.
2 replies
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
-
I wanted to create a shared
.env
file that containsand then have all my docker containers access it. I'm trying to do this in Synology's Container Manager, but it always fails at the lines that require the
env
variables. I tried addingto no avail.
I was thinking of having all my docker folders in a docker folder and in that docker folder also have an .env file that my docker compose files can reference:
Is this possible?
Beta Was this translation helpful? Give feedback.
All reactions