I'm running OpenWrt 22.03.0 on a x86 Zimaboard with dockerd installed.
Accessing the internet from inside a container e.g. for obtaining a Let's Encrypt certificate or curl any website alwasy ends with a "connection refused" error. I can access the service running inside a container from WAN and LAN interface, but there is no internet access from inside a container.
Firewall settings are unchanged from stock except opening WAN Port 80 and 443.
root@OpenWrt:/etc/config# cat firewall
config defaults
option input 'ACCEPT'
option output 'ACCEPT'
option forward 'REJECT'
option synflood_protect '1'
config zone
option name 'lan'
list network 'lan'
option input 'ACCEPT'
option output 'ACCEPT'
option forward 'ACCEPT'
config zone
option name 'wan'
option input 'REJECT'
option output 'ACCEPT'
option forward 'REJECT'
option masq '1'
option mtu_fix '1'
list network 'wan'
list network 'wan6'
config forwarding
option src 'lan'
option dest 'wan'
config rule
option name 'Allow-DHCP-Renew'
option src 'wan'
option proto 'udp'
option dest_port '68'
option target 'ACCEPT'
option family 'ipv4'
config rule
option name 'Allow-Ping'
option src 'wan'
option proto 'icmp'
option icmp_type 'echo-request'
option family 'ipv4'
option target 'ACCEPT'
config rule
option name 'Allow-IGMP'
option src 'wan'
option proto 'igmp'
option family 'ipv4'
option target 'ACCEPT'
config rule
option name 'Allow-DHCPv6'
option src 'wan'
option proto 'udp'
option dest_port '546'
option family 'ipv6'
option target 'ACCEPT'
config rule
option name 'Allow-MLD'
option src 'wan'
option proto 'icmp'
option src_ip 'fe80::/10'
list icmp_type '130/0'
list icmp_type '131/0'
list icmp_type '132/0'
list icmp_type '143/0'
option family 'ipv6'
option target 'ACCEPT'
config rule
option name 'Allow-ICMPv6-Input'
option src 'wan'
option proto 'icmp'
list icmp_type 'echo-request'
list icmp_type 'echo-reply'
list icmp_type 'destination-unreachable'
list icmp_type 'packet-too-big'
list icmp_type 'time-exceeded'
list icmp_type 'bad-header'
list icmp_type 'unknown-header-type'
list icmp_type 'router-solicitation'
list icmp_type 'neighbour-solicitation'
list icmp_type 'router-advertisement'
list icmp_type 'neighbour-advertisement'
option limit '1000/sec'
option family 'ipv6'
option target 'ACCEPT'
config rule
option name 'Allow-ICMPv6-Forward'
option src 'wan'
option dest '*'
option proto 'icmp'
list icmp_type 'echo-request'
list icmp_type 'echo-reply'
list icmp_type 'destination-unreachable'
list icmp_type 'packet-too-big'
list icmp_type 'time-exceeded'
list icmp_type 'bad-header'
list icmp_type 'unknown-header-type'
option limit '1000/sec'
option family 'ipv6'
option target 'ACCEPT'
config rule
option name 'Allow-IPSec-ESP'
option src 'wan'
option dest 'lan'
option proto 'esp'
option target 'ACCEPT'
config rule
option name 'Allow-ISAKMP'
option src 'wan'
option dest 'lan'
option dest_port '500'
option proto 'udp'
option target 'ACCEPT'
config zone 'docker'
option input 'ACCEPT'
option output 'ACCEPT'
option forward 'ACCEPT'
option name 'docker'
list network 'docker'
config rule
option name 'Allow-HTTP-WAN'
list proto 'tcp'
option src 'wan'
option dest_port '80'
option target 'ACCEPT'
config rule
option name 'Allow-HTTPS-WAN'
list proto 'tcp'
option src 'wan'
option dest_port '443'
option target 'ACCEPT'
root@OpenWrt:~# netstat -lpn
Active Internet connections (only servers)
Proto Recv-Q Send-Q Local Address Foreign Address State PID/Program name
tcp 0 0 0.0.0.0:80 0.0.0.0:* LISTEN 4179/docker-proxy
tcp 0 0 0.0.0.0:8080 0.0.0.0:* LISTEN 2284/uhttpd
tcp 0 0 127.0.0.1:53 0.0.0.0:* LISTEN 3597/dnsmasq
tcp 0 0 192.168.1.1:53 0.0.0.0:* LISTEN 3597/dnsmasq
tcp 0 0 172.17.0.1:53 0.0.0.0:* LISTEN 3597/dnsmasq
tcp 0 0 172.18.0.1:53 0.0.0.0:* LISTEN 3597/dnsmasq
tcp 0 0 172.19.0.1:53 0.0.0.0:* LISTEN 3597/dnsmasq
tcp 0 0 0.0.0.0:22 0.0.0.0:* LISTEN 1987/dropbear
tcp 0 0 0.0.0.0:443 0.0.0.0:* LISTEN 4135/docker-proxy
tcp 0 0 0.0.0.0:8443 0.0.0.0:* LISTEN 2284/uhttpd
tcp 0 0 0.0.0.0:8000 0.0.0.0:* LISTEN 4067/docker-proxy
tcp 0 0 192.168.1.1:7681 0.0.0.0:* LISTEN 2899/ttyd
tcp 0 0 0.0.0.0:9443 0.0.0.0:* LISTEN 4014/docker-proxy
tcp 0 0 :::80 :::* LISTEN 4185/docker-proxy
tcp 0 0 :::8080 :::* LISTEN 2284/uhttpd
tcp 0 0 fe80::c486:10ff:fe34:928:53 :::* LISTEN 3597/dnsmasq
tcp 0 0 fe80::d88a:ecff:fea0:145f:53 :::* LISTEN 3597/dnsmasq
tcp 0 0 2001:a61:13b1:6400::1:53 :::* LISTEN 3597/dnsmasq
tcp 0 0 fe80::bc9d:6cff:fe8d:400f:53 :::* LISTEN 3597/dnsmasq
tcp 0 0 fe80::8ce3:f8ff:fee9:f33e:53 :::* LISTEN 3597/dnsmasq
tcp 0 0 fe80::42:cff:fec9:32b1:53 :::* LISTEN 3597/dnsmasq
tcp 0 0 fe80::1045:9bff:fe84:8071:53 :::* LISTEN 3597/dnsmasq
tcp 0 0 fe80::3435:a3ff:fe6b:8992:53 :::* LISTEN 3597/dnsmasq
tcp 0 0 fe80::42:a6ff:fecc:b077:53 :::* LISTEN 3597/dnsmasq
tcp 0 0 fe80::2e0:4cff:fe68:991:53 :::* LISTEN 3597/dnsmasq
tcp 0 0 fe80::42:d3ff:fe06:27ac:53 :::* LISTEN 3597/dnsmasq
tcp 0 0 fe80::2e0:4cff:fe68:991:53 :::* LISTEN 3597/dnsmasq
tcp 0 0 ::1:53 :::* LISTEN 3597/dnsmasq
tcp 0 0 fd3e:1a65:d719::1:53 :::* LISTEN 3597/dnsmasq
tcp 0 0 fe80::2e0:4cff:fe68:990:53 :::* LISTEN 3597/dnsmasq
tcp 0 0 :::22 :::* LISTEN 1987/dropbear
tcp 0 0 :::443 :::* LISTEN 4144/docker-proxy
tcp 0 0 :::8443 :::* LISTEN 2284/uhttpd
tcp 0 0 :::8000 :::* LISTEN 4076/docker-proxy
tcp 0 0 :::9443 :::* LISTEN 4026/docker-proxy
udp 0 0 127.0.0.1:53 0.0.0.0:* 3597/dnsmasq
udp 0 0 192.168.1.1:53 0.0.0.0:* 3597/dnsmasq
udp 0 0 172.17.0.1:53 0.0.0.0:* 3597/dnsmasq
udp 0 0 172.18.0.1:53 0.0.0.0:* 3597/dnsmasq
udp 0 0 172.19.0.1:53 0.0.0.0:* 3597/dnsmasq
udp 0 0 0.0.0.0:67 0.0.0.0:* 3597/dnsmasq
udp 0 0 fe80::c486:10ff:fe34:928:53 :::* 3597/dnsmasq
udp 0 0 fe80::d88a:ecff:fea0:145f:53 :::* 3597/dnsmasq
udp 0 0 2001:a61:13b1:6400::1:53 :::* 3597/dnsmasq
udp 0 0 fe80::bc9d:6cff:fe8d:400f:53 :::* 3597/dnsmasq
udp 0 0 fe80::8ce3:f8ff:fee9:f33e:53 :::* 3597/dnsmasq
udp 0 0 fe80::42:cff:fec9:32b1:53 :::* 3597/dnsmasq
udp 0 0 fe80::1045:9bff:fe84:8071:53 :::* 3597/dnsmasq
udp 0 0 fe80::3435:a3ff:fe6b:8992:53 :::* 3597/dnsmasq
udp 0 0 fe80::42:a6ff:fecc:b077:53 :::* 3597/dnsmasq
udp 0 0 fe80::2e0:4cff:fe68:991:53 :::* 3597/dnsmasq
udp 0 0 fe80::42:d3ff:fe06:27ac:53 :::* 3597/dnsmasq
udp 0 0 fe80::2e0:4cff:fe68:991:53 :::* 3597/dnsmasq
udp 0 0 ::1:53 :::* 3597/dnsmasq
udp 0 0 fd3e:1a65:d719::1:53 :::* 3597/dnsmasq
udp 0 0 fe80::2e0:4cff:fe68:990:53 :::* 3597/dnsmasq
udp 0 0 :::546 :::* 5231/odhcp6c
udp 0 0 :::547 :::* 2157/odhcpd
raw 0 0 ::%721840896:58 :::* 58 5231/odhcp6c
raw 0 0 ::%721840896:58 :::* 58 2157/odhcpd
Active UNIX domain sockets (only servers)
Proto RefCnt Flags Type State I-Node PID/Program name Path
unix 2 [ ACC ] STREAM LISTENING 10673 8339/containerd-shi /run/containerd/s/f3b20ac5af59a53b3a4a23d5b5f2f30274823cc4ada8bf4ab5fc85910a7981a7
unix 2 [ ACC ] STREAM LISTENING 3091 1338/ubusd /var/run/ubus/ubus.sock
unix 2 [ ACC ] STREAM LISTENING 2990 4238/containerd-shi /run/containerd/s/0157d2804baee3efb9d20c45f1d9b128a417948cba41b6fd936d6f45cc15a477
unix 2 [ ACC ] STREAM LISTENING 6175 4275/containerd-shi /run/containerd/s/335d6e83471f27f732a387fefdf579716171a6f05561d841acc883440f85eb04
unix 2 [ ACC ] STREAM LISTENING 4640 4302/containerd-shi /run/containerd/s/40a0ca64535e01852deffebe007c434a8955c2670d66deac20f69a75d01d06ce
unix 2 [ ACC ] STREAM LISTENING 3009 4331/containerd-shi /run/containerd/s/beb7426e3aca4f67ce27cc2d716dd42228f8457d83227d22c12a232d40924bc4
unix 2 [ ACC ] STREAM LISTENING 3571 2844/dockerd /var/run/docker.sock
unix 2 [ ACC ] STREAM LISTENING 4191 3038/containerd /var/run/docker/containerd/containerd-debug.sock
unix 2 [ ACC ] STREAM LISTENING 4192 3038/containerd /var/run/docker/containerd/containerd.sock.ttrpc
unix 2 [ ACC ] STREAM LISTENING 4193 3038/containerd /var/run/docker/containerd/containerd.sock
unix 2 [ ACC ] STREAM LISTENING 3616 2844/dockerd /var/run/docker/metrics.sock
unix 2 [ ACC ] STREAM LISTENING 1901 2844/dockerd /var/run/docker/libnetwork/6f64a8c42f04.sock
root@OpenWrt:~# docker ps
CONTAINER ID IMAGE COMMAND CREATED STATUS PORTS NAMES
366b8f388ee3 joplin/server:latest "tini -- node dist/a…" About an hour ago Up 18 seconds joplin
59bc54a10be6 postgres:13 "docker-entrypoint.s…" About an hour ago Up 5 minutes 5432/tcp joplin_postgres
ca43315d05ce jwilder/nginx-proxy:alpine "/app/docker-entrypo…" About an hour ago Up 5 minutes 0.0.0.0:80->80/tcp, :::80->80/tcp, 0.0.0.0:443->443/tcp, :::443->443/tcp nginx-proxy
a99bb9f1988f jrcs/letsencrypt-nginx-proxy-companion "/bin/bash /app/entr…" About an hour ago Up 5 minutes nginx-proxy-letsencrypt
693f7b153f73 portainer/portainer-ce "/portainer" About an hour ago Up 5 minutes 0.0.0.0:8000->8000/tcp, :::8000->8000/tcp, 0.0.0.0:9443->9443/tcp, :::9443->9443/tcp, 9000/tcp portainer
root@OpenWrt:~# iptables-save -c
# Generated by iptables-save v1.8.7 on Mon Sep 12 09:00:49 2022
*nat
:PREROUTING ACCEPT [1797:463441]
:INPUT ACCEPT [619:41112]
:OUTPUT ACCEPT [440:30589]
:POSTROUTING ACCEPT [87:6386]
:DOCKER - [0:0]
[691:44617] -A PREROUTING -m addrtype --dst-type LOCAL -j DOCKER
[0:0] -A OUTPUT ! -d 127.0.0.0/8 -m addrtype --dst-type LOCAL -j DOCKER
[0:0] -A POSTROUTING -s 172.17.0.0/16 ! -o docker0 -j MASQUERADE
[0:0] -A POSTROUTING -s 172.19.0.0/16 ! -o br-joplin -j MASQUERADE
[0:0] -A POSTROUTING -s 172.18.0.0/16 ! -o br-9fb15ae64b88 -j MASQUERADE
[0:0] -A POSTROUTING -s 172.17.0.2/32 -d 172.17.0.2/32 -p tcp -m tcp --dport 9443 -j MASQUERADE
[0:0] -A POSTROUTING -s 172.17.0.2/32 -d 172.17.0.2/32 -p tcp -m tcp --dport 8000 -j MASQUERADE
[0:0] -A POSTROUTING -s 172.18.0.3/32 -d 172.18.0.3/32 -p tcp -m tcp --dport 443 -j MASQUERADE
[0:0] -A POSTROUTING -s 172.18.0.3/32 -d 172.18.0.3/32 -p tcp -m tcp --dport 80 -j MASQUERADE
[0:0] -A DOCKER -i docker0 -j RETURN
[0:0] -A DOCKER -i br-joplin -j RETURN
[0:0] -A DOCKER -i br-9fb15ae64b88 -j RETURN
[0:0] -A DOCKER ! -i docker0 -p tcp -m tcp --dport 9443 -j DNAT --to-destination 172.17.0.2:9443
[0:0] -A DOCKER ! -i docker0 -p tcp -m tcp --dport 8000 -j DNAT --to-destination 172.17.0.2:8000
[0:0] -A DOCKER ! -i br-9fb15ae64b88 -p tcp -m tcp --dport 443 -j DNAT --to-destination 172.18.0.3:443
[2:80] -A DOCKER ! -i br-9fb15ae64b88 -p tcp -m tcp --dport 80 -j DNAT --to-destination 172.18.0.3:80
COMMIT
# Completed on Mon Sep 12 09:00:49 2022
# Generated by iptables-save v1.8.7 on Mon Sep 12 09:00:49 2022
*mangle
:PREROUTING ACCEPT [538320:1213556947]
:INPUT ACCEPT [2311:295367]
:FORWARD ACCEPT [535385:1212898171]
:OUTPUT ACCEPT [1635:333639]
:POSTROUTING ACCEPT [536967:1213228141]
COMMIT
# Completed on Mon Sep 12 09:00:49 2022
# Generated by iptables-save v1.8.7 on Mon Sep 12 09:00:49 2022
*filter
:INPUT ACCEPT [2158:287424]
:FORWARD ACCEPT [535332:1212894502]
:OUTPUT ACCEPT [1598:331316]
:DOCKER - [0:0]
:DOCKER-ISOLATION-STAGE-1 - [0:0]
:DOCKER-ISOLATION-STAGE-2 - [0:0]
:DOCKER-USER - [0:0]
[535332:1212894502] -A FORWARD -j DOCKER-USER
[535332:1212894502] -A FORWARD -j DOCKER-ISOLATION-STAGE-1
[0:0] -A FORWARD -o docker0 -m conntrack --ctstate RELATED,ESTABLISHED -j ACCEPT
[0:0] -A FORWARD -o docker0 -j DOCKER
[0:0] -A FORWARD -i docker0 ! -o docker0 -j ACCEPT
[0:0] -A FORWARD -i docker0 -o docker0 -j ACCEPT
[0:0] -A FORWARD -o br-joplin -m conntrack --ctstate RELATED,ESTABLISHED -j ACCEPT
[0:0] -A FORWARD -o br-joplin -j DOCKER
[0:0] -A FORWARD -i br-joplin ! -o br-joplin -j ACCEPT
[0:0] -A FORWARD -i br-joplin -o br-joplin -j ACCEPT
[0:0] -A FORWARD -o br-9fb15ae64b88 -m conntrack --ctstate RELATED,ESTABLISHED -j ACCEPT
[0:0] -A FORWARD -o br-9fb15ae64b88 -j DOCKER
[0:0] -A FORWARD -i br-9fb15ae64b88 ! -o br-9fb15ae64b88 -j ACCEPT
[0:0] -A FORWARD -i br-9fb15ae64b88 -o br-9fb15ae64b88 -j ACCEPT
[0:0] -A DOCKER -d 172.17.0.2/32 ! -i docker0 -o docker0 -p tcp -m tcp --dport 9443 -j ACCEPT
[0:0] -A DOCKER -d 172.17.0.2/32 ! -i docker0 -o docker0 -p tcp -m tcp --dport 8000 -j ACCEPT
[0:0] -A DOCKER -d 172.18.0.3/32 ! -i br-9fb15ae64b88 -o br-9fb15ae64b88 -p tcp -m tcp --dport 443 -j ACCEPT
[0:0] -A DOCKER -d 172.18.0.3/32 ! -i br-9fb15ae64b88 -o br-9fb15ae64b88 -p tcp -m tcp --dport 80 -j ACCEPT
[0:0] -A DOCKER-ISOLATION-STAGE-1 -i docker0 ! -o docker0 -j DOCKER-ISOLATION-STAGE-2
[0:0] -A DOCKER-ISOLATION-STAGE-1 -i br-joplin ! -o br-joplin -j DOCKER-ISOLATION-STAGE-2
[0:0] -A DOCKER-ISOLATION-STAGE-1 -i br-9fb15ae64b88 ! -o br-9fb15ae64b88 -j DOCKER-ISOLATION-STAGE-2
[535332:1212894502] -A DOCKER-ISOLATION-STAGE-1 -j RETURN
[0:0] -A DOCKER-ISOLATION-STAGE-2 -o docker0 -j DROP
[0:0] -A DOCKER-ISOLATION-STAGE-2 -o br-joplin -j DROP
[0:0] -A DOCKER-ISOLATION-STAGE-2 -o br-9fb15ae64b88 -j DROP
[0:0] -A DOCKER-ISOLATION-STAGE-2 -j RETURN
[0:0] -A DOCKER-USER -i eth1.40 -o docker0 -j REJECT --reject-with icmp-port-unreachable
[535332:1212894502] -A DOCKER-USER -j RETURN
COMMIT
# Completed on Mon Sep 12 09:00:49 2022
Thank you for your support