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