Docker Community Forums

Share and learn in the Docker community.

Pass system environment variables in docker

how do you pass a username and password saved in my environment variables in docker?

I tried #1

ENV DATABASE_USERNAME $DATABASE_USERNAME 
ENV DATABASE_PASSWORD $DATABASE_PASSWORD 

#2

ARG DATABASE_USERNAME $DATABASE_USERNAME 
ARG DATABASE_PASSWORD $DATABASE_PASSWORD

ENV DATABASE_USERNAME $DATABASE_USERNAME 
ENV DATABASE_PASSWORD $DATABASE_PASSWORD 

#3 using dockcer compose
version: ‘3.3’

services:
  app:
    build:
      context: .
    environment:
      - DATABASE_USERNAME =${DATABASE_USERNAME }
      - DATABASE_PASSWORD =${DATABASE_PASSWORD }

None of those seem to work, but both DATABASE_PASSWORD and DATABASE_USERNAME are saved name variables in my environment.