I am having some issues trying to restrict access to 2 docker containers I am currently running using Centos8 and Firewalld. First of all, the containers have the following configuration:
services:
service1:
ports:
- 1234:1234
service2:
ports:
- 6969:6969
The docker zone has the following (default)configuration:
docker (active)
target: ACCEPT
icmp-block-inversion: no
interfaces: br-b2ef50b272a2 docker0
sources:
services:
ports:
protocols:
masquerade: no
forward-ports:
source-ports:
icmp-blocks:
When leaving things like this, if I run docker-compose up, the apps are running and there is communication between them but their ports are also accessible through the public internet. My end goal is to have intra communication between the apps, but block access to their ports from the public and only allow specific IPs. What I have done so far and did not work:
- First of all I tried changing the target of the docker zone to
default
That only broke the communication between the 2 applications, and nothing else - Added a rich rule:
rule family="ipv4" source NOT address="X.X.X.X" port port="6969" protocol="tcp" reject
The rule gets ignored.
Is there a way to block access to those ports using FirewallD and docker zone, while at the same the 2 services can communicate with each other?