docker-library / postgres

Docker Official Image packaging for Postgres
http://www.postgresql.org
MIT License
2.16k stars 1.13k forks source link

Running 2 different image versions - cannot use two different passwords via POSTGRES_PASSWORD #1106

Closed vgjenks closed 1 year ago

vgjenks commented 1 year ago

Macbook Pro M2 Max. Docker Desktop 4.20.1

This is the strangest thing, but perhaps someone can clarify what's happening for me. I'm running two different images, because I need two different versions of pg for two different projects. I use 13.3 for one, and 15.3 for the other. Here are my respective commands.

docker run --rm -v /Users/me/docker/postgres/13.3:/var/lib/postgresql/data -p 5432:5432 --name postgres-local-13 -e POSTGRES_PASSWORD=password1 -d postgres:13.3

This works fine...completed a project of two years, shut it down, and started a new one on 15.3:

docker run --rm -v /Users/me/docker/postgres/15.3:/var/lib/postgresql/data -p 5432:5432 --name postgres-local-15 -e POSTGRES_PASSWORD=password2 -d postgres:15.3

Here's the crazy thing - when running 15.3, I can't connect w/ "password2", but I can with "password1" - even though that instance isn't running. How is this possible?

I've verified in DBeaver and the sequelize cli - I have to use the password from the older image, which isn't even running, and doesn't share configuration with the one that IS running.