1

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?

2
  • Check if the variables are accessible in your container with docker-compose config. Do you see your variables? Commented May 15, 2017 at 15:41
  • Nope! :-( I'm using docker-compose version 1.11.2 Commented May 16, 2017 at 5:29

1 Answer 1

1

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

Sign up to request clarification or add additional context in comments.

Comments

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.