Cannot access service using docker-swarm, but without Currently I try to setup docker-swarm using two nodes and deploy portainer on them.
Both nodes are virtual machines on the same host and are on the same network (172.16.255.255). Addtionally there is a firewall in these local network providing a VPN server (255.255.0.0). The VPN routes requests to 172.16.255.255 in the local network (e. g. 10.0.0.3 can access 172.16.0.80). No ports are blocked.
I have no trouble accessing the virtual machines (e. g. by ssh).
I followed the install installation instructions on portainer.io.
Compose File:
version: '3.2'

services:
  agent:
    image: portainer/agent
    volumes:
      - /var/run/docker.sock:/var/run/docker.sock
      - /var/lib/docker/volumes:/var/lib/docker/volumes
    networks:
      - agent_network
    deploy:
      mode: global
      placement:
        constraints: [node.platform.os == linux]

  portainer:
    image: portainer/portainer-ce
    command: -H tcp://tasks.agent:9001 --tlsskipverify
    ports:
      - 9000:9000
      - 8000:8000
    volumes:
      - portainer_data:/data
    networks:
      - agent_network
    deploy:
      mode: replicated
      replicas: 1
      placement:
        constraints: [node.role == manager]

networks:
  agent_network:
    driver: overlay
    attachable: true

volumes:
  portainer_data:

Run  command:
docker stack deploy --compose-file=portainer-agent-stack.yml portainer

The stack is successfully deployed and I can access the portainer UI as long as I'm in the local network. The UI is even accessible from other virtual machines, which are not part of the swarm.
But when I try to access the UI from my VPN, I get a timeout (SYN, but no ACK).
This happen for other container as well (e. g. I tried to test it with jwilder/whoami for different ports).
When I setup a container, with identical settings, without swarm, the service is accessiable via VPN.
The problem was that the vpn network has the subnet 10.0.0.0/8 and the ingress network of docker swarm has the subnet 10.0.0.0/24.
So there were a conflict.
Fix:
Changing either the vpn subnet or the ingress network subnet.