I have a docker container running on a centos machine using the official Postgres docker image and it cannot be connected remotely. sudo docker ps | grep postgres
gives
492192ff9170 postgres "/docker-entrypoint.s" 2 years ago Up 18 hours 0.0.0.0:5432->5432/tcp postgres
when I try psql -h <server domain name> -p 5432 -U postgres
on the other machine, it just printed out
psql: could not connect to server: Operation timed out
Is the server running on host [domain name] ([ip address]) and accepting TCP/IP connections on port 5432?
I did sudo iptables -S | grep 5432
on the remote server and it printed out
-A DOCKER -d 172.17.0.2/32 ! -i docker0 -o docker0 -p tcp -m tcp --dport 5432 -j ACCEPT
so it doesn't looks like port 5432
was blocked
Inside the container /var/lib/postgresql/data/
,host all all 0.0.0.0/0 md5
had been added to the pg_hba.conf
, while
postgresql.conf
has listen_addresses = '*'
specified.
Still, it cannot be accessed remotely, although I can successfully connect to the instance locally using psql -h localhost -p 5432 -U postgres
Could any one shed some lights on this issue? Much appreciated.