Having problems getting a variable from a .env file to work in my docker compose file from a higher directory - Stack Overflow

admin2025-04-16  5

I have my directories set up like this

>
.env
    >unmanic
        compose.yml
    >overseer
        compose.yml

My unmanic compose.yml looks like this

version: "3"
services:
  unmanic:
    container_name: unmanic
    image: josh5/unmanic:latest
    ports:
      - 8888:8888
    restart: unless-stopped
    networks:
      - unabatedshagie
    env_file: /srv/dev-disk-by-uuid-f94e80d8-a1e4-4ee9-8ca1-dbef7eb0d715/_docker_configs/dockge_stacks_optiplex/.env
    volumes:
      - ${DOCKERDATAPATH}/unmanic:/config
      - ${MOVIES}:/movies

more-media networks: unabatedshagie: name: unabatedshagie external: true

My .env file looks like this

PUID=1000
PGID=100
TZ=Europe/London
UMASK=002
DOCKERDATAPATH="/srv/dev-disk-by-uuid-f94e80d8-a1e4-4ee9-8ca1-dbef7eb0d715/_docker_configs"
MOVIES="/srv/dev-disk-by-uuid-680132be-a6e7-4aaa-97be-6759d66ddcfe/movies"

This doesn't work. If I remove the env_file: line and move the .env file into the unmanic folder it does work.

Is what I'm trying to do not possible?

It does seem to work if I'm not trying to reference the paths, the PIUD and PGID's get picked up, which is why it's confusing me.

转载请注明原文地址:http://www.anycun.com/QandA/1744749435a87070.html