I run the command:
docker run -it \
-p 5432:5432 \
-e POSTGRES_PASSWORD=first \
-e POSTGRES_USER=first \
-v `pwd`/temp:/var/lib/postgresql/data \
postgres:16
And I can log into the database with the username first and the password first:
~$ PGPASSWORD=first psql -h 127.0.0.1 -U first -d first
psql (15.6 (Debian 15.6-0+deb12u1), server 16.1 (Debian 16.1-1.pgdg120+1))
WARNING: psql major version 15, server major version 16.
Some psql features might not work.
Type "help" for help.
first=#
I then stop that container and run the following command in the same directory:
docker run -it \
-p 5432:5432 \
-e POSTGRES_PASSWORD=second\
-e POSTGRES_USER=second \
-v `pwd`/temp:/var/lib/postgresql/data \
postgres:16
And I cannot log in as second!! (I can still log in as first)
~$ PGPASSWORD=second psql -h 127.0.0.1 -U second
psql: error: connection to server at "127.0.0.1", port 5432 failed: FATAL: password authentication failed for user "second"
I run the command:
docker run -it \ -p 5432:5432 \ -e POSTGRES_PASSWORD=first \ -e POSTGRES_USER=first \ -v `pwd`/temp:/var/lib/postgresql/data \ postgres:16And I can log into the database with the username
firstand the passwordfirst:I then stop that container and run the following command in the same directory:
docker run -it \ -p 5432:5432 \ -e POSTGRES_PASSWORD=second\ -e POSTGRES_USER=second \ -v `pwd`/temp:/var/lib/postgresql/data \ postgres:16And I cannot log in as second!! (I can still log in as first)