title: how to connect an application in tomcat container to a postgres container created in the same network?
body: <p>I am running a tomcat based application inside a container, and a Postgres database container on my <strong>ubuntu</strong> host using docker compose. They are in same docker bridge network defined by me. I have my <strong>firewall enabled</strong>. My firewall doesn't have any deny rule for 5432 port. When my firewall is disabled, my tomcat application can connect to a database container by using either its IP or service name. But when the firewall is enabled, it does not connect to the database container. I have set DOCKER_OPTS="--iptables=false" in docker.conf and restarted docker. Why it is not connecting when firewall is enabled?</p>
  
  <p>1)These are my active rules:-</p>
  
  <p>To                         Action      From<br>
  --                         ------      ----<br>
  2377/tcp                   ALLOW       Anywhere<br>
  7946/tcp                   ALLOW       Anywhere<br>
  7946/udp                   ALLOW       Anywhere<br>
  4789/udp                   ALLOW       Anywhere<br>
  22                         ALLOW       Anywhere<br>
  8443                       ALLOW       10.20.220.185<br>
  8443                       ALLOW       10.20.220.78<br>
  8081                       ALLOW       10.5.0.7<br>
  5432                       ALLOW       Anywhere<br>
  8081                       ALLOW       10.5.0.5<br>
  2377/tcp (v6)              ALLOW       Anywhere (v6)<br>
  7946/tcp (v6)              ALLOW       Anywhere (v6)<br>
  7946/udp (v6)              ALLOW       Anywhere (v6)<br>
  4789/udp (v6)              ALLOW       Anywhere (v6)<br>
  22 (v6)                    ALLOW       Anywhere (v6)<br>
  5432 (v6)                  ALLOW       Anywhere (v6)<br></p>
  
  <p>=========================================================================</p>
  
  <p>2)These is my application configuration to connect to database using service name:-
  <code>driverClass=org.postgresql.Driver
  jdbcUrl=jdbc:postgresql://PostgresDatabase:5432/dockerdb
  user=dockeruser</code></p>