[SOLVED] Docker compose without "network_mode: host"

Hi everyone,

openhab runs in docker using compose.yml. Because I have two nics, I want to bind openhab to one nic. As far as I understand it, the docker-host network cannot be bound to a certain nic.

That’s why I created my own bridge network for openhab and specified the corresponding ports in the compose.yml.

[...] 
   ports:
      - 8080:8080
      - 8443:8443
      - 8101:8101
[...]

That works, but for example the connection to my knx-items doesn’t work. Adding port 3671 does not help.

I will probably have to add more ports. But which ports? Is there a list of commonly used ports?

Or is there another way to reach openhab only via nic1, but not via nic2?

Thanks a lot!

Finally I’ve made it. At least it seems so. Openhab is running in bridge-mode, bound to nic1. I had to change my knx.things from route to tunnel. This is how it´s working now:

openhab.yml:

version: "3.7"
services:

# Openhab
  openhab:
    container_name: openhab
    image: openhab/openhab:latest
    restart: always
    ports:
      - 8080:8080
      - 8443:8443
      - 8101:8101
      - 3671:3671
      - 3671:3671/udp
      - 5007:5007
      - 1012:1012
    volumes:
      - /etc/localtime:/etc/localtime:ro
      - /etc/timezone:/etc/timezone:ro
      - /opt/openhab/addons:/openhab/addons
      - /opt/openhab/conf:/openhab/conf
      - /opt/openhab/userdata:/openhab/userdata
    environment:
      OPENHAB_HTTP_PORT: "8080"
      OPENHAB_HTTPS_PORT: "8443"
      EXTRA_JAVA_OPTS: "-Duser.timezone=Europe/Berlin"

networks:
  default:
    external:
      name: openhab-net

knx.things:

Bridge knx:ip:bridge "Enertex Secure Router" [ 
    type="TUNNEL",
    ipAddress="192.168.178.200", 
    portNumber=3671,
    useNAT=true, 
    localSourceAddr="0.0.0"
]
1 Like