I have the same issue. There must be a missing or conflicting firewall rule because it works if I stop the firewall. Docker’s firewall rules seems to be added but I’ve not spent the time to figure out what’s wrong and how to fix it.
I just ran into what appears to be the same issue today. I have host.docker.internal set in my /etc/hosts file on NixOS, but the docker containers I am running cannot access it from inside the container. It just works fine for my buddy running the same stack on M1 Mac with docker deskop (and without any Nix stuff).
Did anyone of you two have any luck with finding out the reason? @ivann or @timjnz?
Any luck here? I haven’t seen the issue as I don’t use NixOS much anymore for Docker stuff and haven’t tested anything but I’m curious as I did depend on something like this just the other month and would be dismayed if I could no longer do it on NixOS
this accepts all incoming tcp and udp packets from interface docker0 to the host (172.17.0.1) .
only to find out that docker0 is (at least on my system) the interface for the default bridge network so containers on a different network still don’t have access to the host.
docker seems to use ip addresses 172.16.x.x-172.31.x.x which is 172.16.0.0/12 for its networks soo
note that i use -I INPUT <N> (insert chain=INPUT position==1>) because nixos added a rule that would otherwise take precedence over those.
also i have 2 rules for tcp and udp
i also read something somewhere about a difference between extraCommands and extraStopCommands . something about not being idempotent. so if anyone knows the fix i would appreciate a fix.