martins
martins

Reputation: 10009

Variables set in .env is not present inside the docker container

I have added a few variables in a .env file.

e.g.

POSTGRES_USER=user
POSTGRES_PASSWORD=pass

Postgres does not create a user with those credentials.

I can not see them when I run docker exec -it $(docker ps | ack postgre | cut -f1 -d\ ) env either.

Why isn't the environnment variables I set in .env honored when I start docker-compose?

Upvotes: 1

Views: 96

Answers (1)

martins
martins

Reputation: 10009

Turns out that one has to tell docker-compose that an .env file exists:

e.g.

web:
  env_file:
    - web-variables.env

https://docs.docker.com/compose/environment-variables/#the-envfile-configuration-option

Upvotes: 1

Related Questions