dockge icon indicating copy to clipboard operation
dockge copied to clipboard

Dockage Can't See ".env" files

Open F1zzyD opened this issue 1 year ago • 1 comments

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

  • [x] I checked and didn't find similar issue

🛡️ Security Policy

Description

It appears that Dockage is not able to see or read .env files correctly. Here's my setup:

dockage compose.yaml

services:
  dockge:
    container_name: dockage
    image: louislam/dockge:1
    restart: unless-stopped
    ports:
      # Host Port : Container Port
      - 5001:5001
    volumes:
      - /var/run/docker.sock:/var/run/docker.sock
      - ./data:/app/data
        
      # If you want to use private registries, you need to share the auth file with Dockge:
      # - /root/.docker/:/root/.docker

      # Stacks Directory
      # ⚠️ READ IT CAREFULLY. If you did it wrong, your data could end up writing into a WRONG PATH.
      # ⚠️ 1. FULL path only. No relative path (MUST)
      # ⚠️ 2. Left Stacks Path === Right Stacks Path (MUST)
      - ./opt/stacks:/opt/stacks
    environment:
      # Tell Dockge where is your stacks directory
      - DOCKGE_STACKS_DIR=/home/user/services/dockage/opt/stacks

Snippet from a container using an .env

services:
  web:
    container_name: test
    env_file:
      -  /home/user/services/web/.env

Yes, I want my .env file located in a specific directory. I've tried multiple ways of formatting it for Dockage to see, but every time I've gone to do docker compose up the container complains it can't see the file, even though I can open it, read it, and edit it.

👟 Reproduction steps

See above

👀 Expected behavior

It should work lol

😓 Actual Behavior

It don't work lol

Dockge Version

1.5.0

💻 Operating System and Arch

Ubuntu 20.04

🌐 Browser

Firefox

🐋 Docker Version

No response

🟩 NodeJS Version

No response

📝 Relevant log output

env file /home/user/services/web/.env not found: stat /home/user/services/web/.env: no such file or directory

F1zzyD avatar Apr 06 '25 01:04 F1zzyD

To my understanding, this is a user configuration error. Re-read the comments pertaining to the stacks directory.

You must not use a relative path. You have used a relative path. Both sides of the volume mount string need to be identical. The environment variable DOCKGE_STACKS_DIR needs to be the same path defined above.

So, minus the comments, your volumes & environment should look like this:

    volumes:
      - /var/run/docker.sock:/var/run/docker.sock
      - ./data:/app/data
      - /home/user/services/dockage/opt/stacks:/home/user/services/dockage/opt/stacks
    environment:
      - DOCKGE_STACKS_DIR=/home/user/services/dockage/opt/stacks

As to why dockge is this particular, my best guess is that it's related to it playing nice with native compose and being able to freely switch between using dockge and the terminal without either spinning up your containers as a new stack.

Jekotia avatar Apr 11 '25 16:04 Jekotia