Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

.env variables are not making it inside the container #656

Open
2 tasks done
tueboesen opened this issue Nov 1, 2024 · 1 comment
Open
2 tasks done

.env variables are not making it inside the container #656

tueboesen opened this issue Nov 1, 2024 · 1 comment
Labels
bug Something isn't working

Comments

@tueboesen
Copy link

⚠️ Please verify that this bug has NOT been reported before.

  • I checked and didn't find similar issue

🛡️ Security Policy

Description

I have the following docker-compose.yml file:

version: "3"

services:
  pihole:
    container_name: pihole
    image: pihole/pihole:latest
    ports:
      - "53:53/tcp" # DNS TCP
      - "53:53/udp" # DNS UDP
      - "${PORT_PIHOLE}:80/tcp" # Comment out this line when traefik is working to close the port.
      #- "67:67/udp" # Only required if you are using Pi-hole as your DHCP server
    environment:
      TZ: ${TZ}
      WEBPASSWORD: '1234'
    volumes:
      - ${LOCAL_BASE_PATH}/pihole/data:/etc/pihole
      - ${LOCAL_BASE_PATH}/pihole/dnsmasq:/etc/dnsmasq.d
#    cap_add:
#      - NET_ADMIN # Required if you are using Pi-hole as your DHCP server, else not needed
    restart: unless-stopped
    networks:
      - proxy
    labels:
      - "traefik.enable=true"
      - "traefik.docker.network=proxy"
      - "traefik.http.routers.${TRAEFIK_SERVICE_NAME}.rule=Host(`pihole.${DOMAIN}`)"
      - "traefik.http.routers.${TRAEFIK_SERVICE_NAME}.entrypoints=https"
      - "traefik.http.routers.${TRAEFIK_SERVICE_NAME}.tls=true"
      - "traefik.http.services.${TRAEFIK_SERVICE_NAME}.loadbalancer.server.port=80" # This has to be the internal docker port, not the external port
      - "traefik.http.middlewares.admin-add-prefix.addprefix.prefix=/admin"
      - "traefik.http.routers.${TRAEFIK_SERVICE_NAME}.middlewares=admin-add-prefix"

networks:
  proxy:
    external: true

And the following .env file, both in the same folder

DOMAIN=mydomain.com
PUID=568
PGID=568
TZ=Europe/Copenhagen
NAS_BASE_PATH=/mnt/DataStore/docker/data # Location on the nas for all docker configs, this is not meant to hold large data amounts.
LOCAL_BASE_PATH=/mnt/DataStore/docker/data # Location on the local storage for all docker configs, this is meant for databases and similar that should not exist on nfs mounted drives.
NAS_MEDIA_PATH=/mnt/DataStore/media
NAS_PHOTOS_PATH=/mnt/DataStore/photos/
NAS_BOOKS_PATH=/mnt/DataStore/media/books
NAS_DOCUMENTS_PATH=/mnt/DataStore/Documents
SSD_TRANSCODING_PATH=/mnt/SSD/Transcoding
PORT_IMMICH=2283
PORT_CALIBRE=2284
PORT_CALIBRE_WEB=2285
PORT_NEXTCLOUD=2286
PORT_TRAEFIK=2287
PORT_TANDOOR=2288
PORT_JOPLIN=2289
PORT_PROWLARR=2290
PORT_RADARR=2291
PORT_LIDARR=2292
PORT_BAZARR=2293
PORT_SONARR=2294
PORT_READARR=2295
PORT_JELLYFIN=2296
PORT_JELLYSEERR=2297
PORT_QBITTORRENT_VPN=2298
PORT_QBITTORRENT_NO_VPN=2299
PORT_PIHOLE=22999
PORT_RADARR4k=3000
PORT_SONARR4k=3001
TORRENTING_PORT_NO_VPN=53108
TRAEFIK_SERVICE_NAME=pihole

Both the files are placed in a folder called pihole, inside a folder called docker_stack:

tue@truenas:/mnt/DataStore/docker/docker_stack/pihole$ ls -la
total 23
drwxr-xr-x  2 root root    5 Nov  1 13:16 .
drwxr-xr-x 13 root root   16 Oct 30 20:57 ..
-rw-r--r--  1 root root 1143 Nov  1 09:48 .env
-rw-r--r--  1 root root 1294 Oct 30 20:56 README.md
-rw-r--r--  1 root root 1338 Nov  1 13:16 docker-compose.yml

I have Dockge running and I can make it start pihole without any problems. However, when I start pihole inside dockge, I can then step into the container using the little bash icon. Inside the container I print the environment and get:

root@ed1c7645e536:/# env
S6_BEHAVIOUR_IF_STAGE2_FAILS=2
HOSTNAME=ed1c7645e536
S6_CMD_WAIT_FOR_SERVICES_MAXTIME=0
PWD=/
TZ=Etc/UTC
HOME=/root
FTLCONF_LOCAL_IPV4=0.0.0.0
TERM=xterm
FTL_CMD=no-daemon
IPv6=True
PHP_ERROR_LOG=/var/log/lighttpd/error-pihole.log
SHLVL=1
phpver=php
DNSMASQ_USER=pihole
WEBPASSWORD=1234
PATH=/opt/pihole:/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin
S6_KEEP_ENV=1
_=/usr/bin/env

But note how TZ=Etc/UTC, even though it should be set to Europe/Copenhagen according to the .env file. If I shut down the container and instead spin up the container using sudo docker compose up -d inside the pihole folder I instead get the correct env variables when I test it inside the container.

👟 Reproduction steps

See the above for a step by step guide

👀 Expected behavior

I expected that the variables from the environment: section of the docker-compose.yml file were loaded correctly into the container.

😓 Actual Behavior

It does not load the env variables

Dockge Version

1.0.17

💻 Operating System and Arch

Truenas scale 24.10

🌐 Browser

Firefox 132.0

🐋 Docker Version

27.1.1

🟩 NodeJS Version

No response

📝 Relevant log output

No response

@tueboesen tueboesen added the bug Something isn't working label Nov 1, 2024
@Hoempi
Copy link

Hoempi commented Nov 1, 2024

I noticed the same thing. Adding env_file: - .env works as a workaround for me.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

2 participants