Hi,
I switched to firewalld
and when having iptables: true
inside /etc/docker/daemon.json
all containers mapped to the host were reachable from internet. After reading forums I saw turning it off like iptables: false
and rebooting was correctly creating a docker
zone for firewalld
that looks like:
<?xml version="1.0" encoding="utf-8"?>
<zone version="1.0" target="ACCEPT">
<short>docker</short>
<description>zone for docker bridge network interfaces</description>
<forward/>
</zone>
Then in my “public” zone I just had to allow container ports that were bound to the host. And the inbound traffic was reaching wanted my containers, great.
Unfortunately when trying a command like docker run --rm curlimages/curl https://curl.se
, I end with curl: (6) Could not resolve host: curl.se
. The traffic from a container cannot reach internet whereas it can go to another container (like a database), and from my server I can perform the same curl directly with OK response.
Any idea how can I solve this? I’m totally lost
Thank you,
For records, here what I had with sudo iptables -n -L
when docker had iptables: true
Chain INPUT (policy ACCEPT)
target prot opt source destination
Chain FORWARD (policy DROP)
target prot opt source destination
DOCKER-USER 0 -- 0.0.0.0/0 0.0.0.0/0
DOCKER-ISOLATION-STAGE-1 0 -- 0.0.0.0/0 0.0.0.0/0
ACCEPT 0 -- 0.0.0.0/0 0.0.0.0/0 ctstate RELATED,ESTABLISHED
DOCKER 0 -- 0.0.0.0/0 0.0.0.0/0
ACCEPT 0 -- 0.0.0.0/0 0.0.0.0/0
ACCEPT 0 -- 0.0.0.0/0 0.0.0.0/0
ACCEPT 0 -- 0.0.0.0/0 0.0.0.0/0 ctstate RELATED,ESTABLISHED
DOCKER 0 -- 0.0.0.0/0 0.0.0.0/0
ACCEPT 0 -- 0.0.0.0/0 0.0.0.0/0
ACCEPT 0 -- 0.0.0.0/0 0.0.0.0/0
Chain OUTPUT (policy ACCEPT)
target prot opt source destination
Chain DOCKER (2 references)
target prot opt source destination
ACCEPT 6 -- 0.0.0.0/0 172.18.0.2 tcp dpt:8080
ACCEPT 6 -- 0.0.0.0/0 172.18.0.2 tcp dpt:443
ACCEPT 6 -- 0.0.0.0/0 172.18.0.2 tcp dpt:80
ACCEPT 6 -- 0.0.0.0/0 172.18.0.5 tcp dpt:80
ACCEPT 6 -- 0.0.0.0/0 172.18.0.7 tcp dpt:3306
ACCEPT 6 -- 0.0.0.0/0 172.18.0.6 tcp dpt:5432
Chain DOCKER-ISOLATION-STAGE-1 (1 references)
target prot opt source destination
DOCKER-ISOLATION-STAGE-2 0 -- 0.0.0.0/0 0.0.0.0/0
DOCKER-ISOLATION-STAGE-2 0 -- 0.0.0.0/0 0.0.0.0/0
RETURN 0 -- 0.0.0.0/0 0.0.0.0/0
Chain DOCKER-ISOLATION-STAGE-2 (2 references)
target prot opt source destination
DROP 0 -- 0.0.0.0/0 0.0.0.0/0
DROP 0 -- 0.0.0.0/0 0.0.0.0/0
RETURN 0 -- 0.0.0.0/0 0.0.0.0/0
Chain DOCKER-USER (1 references)
target prot opt source destination
RETURN 0 -- 0.0.0.0/0 0.0.0.0/0
And here what it has with iptables: false
:
Chain INPUT (policy ACCEPT)
target prot opt source destination
Chain FORWARD (policy ACCEPT)
target prot opt source destination
Chain OUTPUT (policy ACCEPT)
target prot opt source destination
(I know firewalld has a different mechanism, but I just wanted to bring more context)
EDIT: I posted some advancement in a reply here, but the bot has hid my message
EDIT2: my post is still hidden, so here the final “solution/workaround” I ended with: Had hard times with `firewalld` and Docker · coollabsio/coolify · Discussion #3433 · GitHub