jlesage / docker-firefox

Docker container for Firefox
MIT License
1.61k stars 288 forks source link

How to set environment variables in docker-compose.yaml? #48

Closed WalterWampe closed 4 years ago

WalterWampe commented 4 years ago

I am struggeling with writing my docker-compose and set my resolution. Currently it looks like this:

 version: '3'
services:
  firefox:
    container_name: firefox
    image: jlesage/firefox
    ports:
      - "5800:5800"
    volumes:
      - "/opt/firefox:/config:rw"
    restart: unless-stopped
    shm_size: '1g'
    build: .
    environment:
      - DISPLAY_WIDTH:2560
      - DISPLAY_HEIGHT:1440`

is this correct?

WalterWampe commented 4 years ago

Nevermind, i figured it out. If anyone else struggles with this, here is the solution: In the same folder create a file .env which contains your variables:

DISPLAY_WIDTH=2560
DISPLAY_HEIGHT=1440
KEEP_APP_RUNNING=1
VNC_PASSWORD=test

then in your docker-copose file access them like this:

version: '3'
services:
  firefox:
    container_name: firefox
    image: jlesage/firefox
    ports:
      - "5800:5800"
    volumes:
      - "/opt/firefox:/config:rw"
    restart: unless-stopped
    shm_size: '1g'
    build: .
    environment:
      - VNC_PASSWORD=${VNC_PASSWORD}
      - DISPLAY_WIDTH=${DISPLAY_WIDTH}
      - DISPLAY_HEIGHT=${DISPLAY_HEIGHT}
      - KEEP_APP_RUNNING=${KEEP_APP_RUNNING}

Thats it!

jlesage commented 4 years ago

I think that your original issue was the usage of : instead of =. It should be:

    environment:
      - DISPLAY_WIDTH=2560
      - DISPLAY_HEIGHT=1440

Instead of:

    environment:
      - DISPLAY_WIDTH:2560
      - DISPLAY_HEIGHT:1440
WalterWampe commented 4 years ago

You are right, thank you!