how to allow both host networking and ingress in docker swarm?

498 views Asked by At

I have a small network of computers, bundled into a docker swarm. I'm running a service that needs host networking, which is fine when it runs on a dedicated node.

But I want to let it run on any node - yet maintaining the ability to access its web UI by connecting to a fixed hostname/IP address, regardless of which node the service is actually running on.

This is normally handled by docker's ingress network, which allows me to connect to a published port on any node's IP address, and routes the connection to the proper node. However, apparently this doesn't work with host networking, and if I specify the ingress network explicitely, it gets rejected.

So, is there a way to both have host networking, while keeping ingress routing? Or what would be the recommended way to let me connect to the service without worrying about which node it's running on at any given moment?

EDIT:

My stack file is the following:

version: '3'
services:
  app:
    image: ghcr.io/home-assistant/home-assistant:stable
    volumes:
      - ...
    privileged: true
    deploy:
      replicas: 1
      restart_policy:
        condition: any
      placement:
        constraints:
          - node.hostname==nas
    networks:
      - host

networks:
  host:
    external: true
0

There are 0 answers