0
  • Include details about your goal

i'm using docker container (php apache), and i need to connect with the postgresql database on my host machine.

ip address of docker0 interface : 172.17.0.1

  • expected and actual results

I test on my container and i have this error :

SQLSTATE[08006] [7] could not connect to server: Connection refused
        Is the server running on host "172.17.0.1" and accepting
        TCP/IP connections on port 5432?

On this server, iptables configuration set up already. I executed this command (seen on stack overflow : How to access host port from docker container) :

sudo iptables -A INPUT -i docker0 -j ACCEPT

a piece of "iptables -S" (just INPUT statements) :

-P INPUT DROP

-A INPUT -p tcp -m multiport --dports 22 -j f2b-sshd
-A INPUT -i bond0.56 -j net-fw
-A INPUT -i bond0.54 -j bkp-fw
-A INPUT -i lo -j ACCEPT
-A INPUT -j Reject
-A INPUT -j LOG --log-prefix "Shorewall:INPUT:REJECT:" --log-level 6
-A INPUT -g reject
-A INPUT -i docker0 -j ACCEPT

I test on my container and i have the same error :

SQLSTATE[08006] [7] could not connect to server: Connection refused
        Is the server running on host "172.17.0.1" and accepting
        TCP/IP connections on port 5432?

I'm beginner on iptables tool, however i wonder many questions :

  • does it my last rule "-A INPUT -i docker0 -j ACCEPT" is useless given that previous command is "-A INPUT -g reject" ?
  • must you analyze other statements set up in iptables ?

Tell me if i must specify other informations. Thanks in advance.

stack80
  • 23
  • 5

0 Answers0