I'm trying to run a PostgreSQL instance on a different port, by setting the port as argument in '-p' however it does not seem to have any effect.
Ex:
docker run --name db_Dev -e POSTGRES_USER=postgres -e POSTGRES_PASSWORD=postgres -e POSTGRES_DB=postgresDev -p 7432:7432 postgres:10.5
Output:
2019-09-15 17:50:29.494 UTC [1] LOG: listening on IPv4 address "0.0.0.0", port 5432
2019-09-15 17:50:29.494 UTC [1] LOG: listening on IPv6 address "::", port 5432
Any idea how to set a different port for it? Thanks
If you want to run multiple Postgres instances or change the listening port of Postgres then follow this.
docker run --name db_Dev -e POSTGRES_USER=postgres -e POSTGRES_PASSWORD=postgres -e POSTGRES_DB=postgresDev -p 7432:5432 postgres:10.5
Here -p 7432:5432
is mapping port 5432 inside your Postgres container on to port 7432 of your host.
Or you can change the listening port 5432 of Postgres by setting environment variable PGPORT
to 7432
.
docker run --name db_Dev -e POSTGRES_USER=postgres -e POSTGRES_PASSWORD=postgres -e POSTGRES_DB=postgresDev -e PGPORT=7432 -p 7432:7432 postgres:10.5
Note: If PGPORT
doesn't work try POSTGRES_PORT
.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With