Docker docs:

Docker routes container traffic in the nat table, which means that packets are diverted before it reaches the INPUT and OUTPUT chains that ufw uses. Packets are routed before the firewall rules can be applied, effectively ignoring your firewall configuration.

you are viewing a single comment's thread
view the rest of the comments
[–] 2 points 1 year ago (3 children)
  • [–] [S] 1 point 1 year ago (2 children)

    That caused issues with Docker containers being unable to communicate with eachother for me.

  • source
  • parent
  • hideshow 2 child comments
  • [–] 2 points 1 year ago (1 child)

    Did you allow the containers to talk to eachother with ufw after setting it up?

  • source
  • parent
  • hideshow 1 child comment
  • [–] [S] 2 points 1 year ago

    Yes, you can fix it by doing this

    echo "Adding rules for Docker subnets to allow communication between containers..."
    for subnet in $(docker network inspect bridge -f '{{range .IPAM.Config}}{{.Subnet}} {{end}}'); 
        sudo ufw allow from $subnet
        echo "Added rule for $subnet"
    done
    
  • source
  • parent