Skip to main content

Centos allow connection between containers

When container was create with docker-compose, ping are allowed between container but http, sql and other ports connections are blocked.

For allow the connection:

sudo firewall-cmd --zone=public --add-masquerade --permanent
sudo firewall-cmd --permanent --zone=public --change-interface=docker0
sudo firewall-cmd --permanent --direct --add-rule ipv4 filter INPUT 4 -i docker0 -j ACCEPT
sudo firewall-cmd --permanent --zone=public --add-port=[YOURPORT]/tcp

Replace [YOURPORT] by the port to allow (80,3306...)

Source

Centos Forum - firewalld and docker