I'am trying to create a simple postgreSQL container with a custum user and database.
This is my docker-compose file :
version: '2'
services:
db.postgres:
container_name: db.postgres
image: postgres:10
environment:
- POSTGRES_USER:'myuser'
- POSTGRES_PASSWORD:'myuserpassword'
- POSTGRES_DB:'mydb'
ports:
- '5432:5432'
volumes:
- ./pgdata:/var/lib/postgresql/data
And the error when I try to connect to my database.
docker exec -it db.postgres psql -U myuser myuserpassword
psql: FATAL: role "myuser" does not exist
OR
$ docker exec -it db.postgres /bin/bash
root@1a0531e0350f:/# psql -U myuser
psql: FATAL: role "myuser" does not exist
Docker-compose environment variables appear to be ignored when creating the database.
I don't known what can I do. Do you have an idea of the problem?
Thanks !