Following this video: https://www.youtube.com/watch?v=G3gnMSyX-XM I've entered the following:
➜ Downloads docker run -p 5432:5432 -d \
-e POSTGRES_PASSWORD=postgres \
-e POSTGRES_USER=postgres \
-e POSTGRES_DB=stripe-example \
-v pgdata:/var/lib/postgresql/data \
postgres
5aaa30effe3282bd06c52b6c71f8343d24df041e9af11a38eb7a1e49453e3fa6
➜ Downloads psql stripe-example -h localhost -U postgres
psql: error: FATAL: role "postgres" does not exist
but am not sure why the role postgres doesn't exist, as it seems I've created that with -e POSTGRES_USER=postgres.
I'm expecting the following (screenshot from this timestamp in the video):
Some updates.
I looked at the docs and dash isn't allowed in database names. If your change the database name to stripe_example, it works. Remember to delete the pgdata volume first, before you try again.
➜ Downloads docker run -p 5432:5432 -d \
-e POSTGRES_PASSWORD=postgres \
-e POSTGRES_USER=postgres \
-e POSTGRES_DB=stripe_example \
-v pgdata:/var/lib/postgresql/data \
postgres
da57c37c8306d5afdb54f8b3cf5e16aa67f97bce85ff4c8d3340e6f3288fb3cd
➜ Downloads psql stripe_example -h localhost -U postgres
psql: error: FATAL: database "stripe_example" does not exist

pgdatavolume already existed with a postgres database in it, then the startup script won't create a new user. If you think that might be the case, then you can remove the volume with the commanddocker volume rm pgdata.psql: error: FATAL: database "stripe-example" does not exist, which I thought was created with-e POSTGRES_DB=stripe-example