Transmission, Docker Compose, and Environment file questions

I have a Transmission container up and running successfully. Everything works, and at the moment, the UI is secured with the environment variables in the compose file. This works, but it means that my passwords are stored in plain text and are visible to anyone that can see my compose files (or is near my monitor when the files are up).

I’d like to secure these variables so they’re not embedded in the actual compose file. I see that it’s possible to set variables from files, but I’m not 100% sure how to do this from a Docker compose file.

I’m working off of this site for reference.

compose.yaml file:

services:
  transmission:
    image: lscr.io/linuxserver/transmission:latest
    container_name: transmission-test
    env_file:
      - transmission.env
    environment:
      - PUID=568
      - PGID=568
      - TZ=America/New_York
      - USER=$USER
      - PASS=$PASS
    volumes:
      - /mnt/data/apps/transmission/config:/config
      - /mnt/data/torrents:/downloads
      - /mnt/data/torrents/watch:/watch
    ports:
      - 30097:9091
      - 51414:51413
      - 51414:51413/udp
    restart: unless-stopped
networks: {}

transmission.env file:

VAR=USER -> SECRETUSER
VAR=PASS -> SECRETPASS

When I try to start the container, I get the following messages:

WARN[0000] The "USER" variable is not set. Defaulting to a blank string.
WARN[0000] The "PASS" variable is not set. Defaulting to a blank string.

Thank you for any help!

Set environment variables | Docker Docs

try with curly braces

I was able to figure it out. Here’s the files:

services:
  transmission:
    image: lscr.io/linuxserver/transmission:latest
    container_name: transmission-test
    env_file:
      - transmission.env
    environment:
      - PUID=568
      - PGID=568
      - TZ=America/New_York
    volumes:
      - /mnt/data/apps/transmission/config:/config
      - /mnt/data/torrents:/downloads
      - /mnt/data/torrents/watch:/watch
    ports:
      - 30097:9091
      - 51414:51413
      - 51414:51413/udp
    restart: unless-stopped
networks: {}
USER="SECRETUSER"
PASS="SECRETPASS"

I didn’t reference the variables in the compose.yaml file, but it picked them up from the .env file. Just tested it, and it’s working perfectly.

This topic was automatically closed 5 days after the last reply. New replies are no longer allowed.