-
Notifications
You must be signed in to change notification settings - Fork 1.2k
Closed
Labels
questionUsability question, not directly related to an error with the imageUsability question, not directly related to an error with the image
Description
(Copy of my SO question)
The docs explain that you can make the image create a user and database on creation, using environment variables.
I can't seem to make that work using docker-compose:
# docker-compose.yml
services:
postgresql:
image: postgres:alpine
environment:
POSTGRES_DB: iotplatform
POSTGRES_USER: iotplatform
POSTGRES_PASSWORD: iotplatform
and here's what I run:
docker-compose up -d --force-recreate postgresql
docker-compose exec postgresql psql -U iotplatform
# psql: FATAL: role "iotplatform" does not exist
When I run docker-compose exec postgresql env, I see the environment variables as configured.
The logs don't say anything particular:
Attaching to iot-container-tracker_postgresql_1
postgresql_1 | 2018-12-17 17:35:05.754 UTC [1] LOG: listening on IPv4 address "0.0.0.0", port 5432
postgresql_1 | 2018-12-17 17:35:05.754 UTC [1] LOG: listening on IPv6 address "::", port 5432
postgresql_1 | 2018-12-17 17:35:05.757 UTC [1] LOG: listening on Unix socket "/var/run/postgresql/.s.PGSQL.5432"
postgresql_1 | 2018-12-17 17:35:05.770 UTC [21] LOG: database system was shut down at 2018-12-17 17:35:03 UTC
postgresql_1 | 2018-12-17 17:35:05.772 UTC [1] LOG: database system is ready to accept connections
postgresql_1 | 2018-12-17 17:35:22.639 UTC [34] FATAL: role "iotplatform" does not exist
Without docker-compose, the variables work fine:
docker run --name some-postgres -e POSTGRES_PASSWORD=iotplatform -e POSTGRES_DB=iotplatform -e POSTGRES_USER=iotplatform -d postgres:alpine
docker exec -it some-postgres psql -U iotplatform
iotplatform=#
What am I missing?
Metadata
Metadata
Assignees
Labels
questionUsability question, not directly related to an error with the imageUsability question, not directly related to an error with the image