We have docker compose.yml
version: '2'
services:
postgres:
image: "library/postgres:latest"
environment:
- POSTGRES_USER=test
- POSTGRES_PASSWORD=qwerty
- POSTGRES_DB=mydb
execute:
docker-compose up
docker exec -it <CONTAINER_ID> /bin/bash
psql -U test
and we get this error:
psql: FATAL: database "test" does not exist
Everything works fine witout compose
docker run -it -e POSTGRES_USER=test -e POSTGRES_PASSWORD=qwerty -e POSTGRES_DATABSE=mydb postgres
docker exec -it <CONTAINER_ID> /bin/bash
psql -U test
results:
root@cb18469bc86e:/# psql -U test
psql (10.1)
Type "help" for help.
test=#
POSTGRES_DB
This optional environment variable can be used to define a different name for the default database that is created when the image is first started. If it is not specified, then the value ofPOSTGRES_USERwill be used.
POSTGRES_DATABSE (from your docker run line) is not used.
thanks a lot! my bad :)
Most helpful comment
POSTGRES_DATABSE(from your docker run line) is not used.