Docker compose environment variable is not set

Viewed 2623

In my docker-compose.yml I set the environment variable PORTUNIQUE but it tells me that the env variable isn't set.

version: "3"

services:
    gateway-service:
      build: ./
      environment: 
        - PORTUNIQUE=8686
      ports:
        - ${PORTUNIQUE}:${PORTUNIQUE}

If I however use a .env file with the following content, it works fine:

PORTUNIQUE=3000

WARNING: The PORTUNIQUE variable is not set. Defaulting to a blank string.

0 Answers
Related