I hope to connect my Postgres docker service from remote client. This is how I create the container:
sudo docker run --name pg -p 5432:5432 -v pg_data:/var/lib/postgres/data -e POSTGRES_DB=mydb -e POSTGRES_USER=dbowner -e POSTGRES_PASSWORD=MySecretPassword -d postgres -c "listen_addresses='*'"
I do research and someone said the file pg_hba.conf
should be edited. How should I edit pg_hba.conf? There has no config parameters to setup the pg_hba.conf
. Also, is there any deferences between host all all all md5
and host all all 0.0.0.0/0 md5
? Which one should I use and how should put it into pg_hba.conf
within the docker container?
Here is the output of netstat
after I create container:
$ netstat -ntl
Active Internet connections (only servers)
Proto Recv-Q Send-Q Local Address Foreign Address State
tcp 0 0 0.0.0.0:80 0.0.0.0:* LISTEN
tcp 0 0 0.0.0.0:22 0.0.0.0:* LISTEN
tcp 0 0 0.0.0.0:443 0.0.0.0:* LISTEN
tcp6 0 0 :::22 :::* LISTEN
tcp6 0 0 :::5432 :::* LISTEN
tcp6 0 0 :::3000 :::* LISTEN
tcp6 0 0 :::4000 :::* LISTEN
tcp6 0 0 :::4001 :::* LISTEN
tcp6 0 0 :::6379 :::* LISTEN
Is that means PostgreSQL service only listen to IPv6?