ualex73 / dsmr-reader-docker

Docker for DSMR-Reader (https://github.com/dennissiemensma/dsmr-reader)
1 stars 2 forks source link

Can't reach mqqt broker #1

Closed wderuijter closed 4 years ago

wderuijter commented 4 years ago

Hoi @ualex73 . When running the docker compose example from https://hub.docker.com/r/ualex73/dsmr-reader-docker/ DSMR reader works like a charm. Only thing is it can't reach my mqtt broker. Tried docker exec dsmr ping 192.168.1.32

My mqqt broker's container is using the host network. The host's (a synology) ip address is 192.168.1.32.

I've altered the docker-compose file so the dsmr container also uses the host network. The container runs and i can ping 192.168.1.32 with docker exec dsmr ping 192.168.1.32. But I cant't reach the web interface at http://192.168.1.32:8888. Am I missing something?

version: '3'
services:
  db-dsmr:
    image: postgres
    container_name: db-dsmr
    volumes:
      - /volume1/docker/dsmr-reader/db:/var/lib/postgresql/data
    restart: unless-stopped
    environment:
      - POSTGRES_USER=dsmrreader
      - POSTGRES_PASSWORD=dsmrreader
      - POSTGRES_DB=dsmrreader
    network_mode: host
  dsmr:
    container_name: dsmr
    image: ualex73/dsmr-reader-docker
    container_name: dsmr
    restart: unless-stopped
    volumes:
      - /volume1/docker/dsmr-reader/backups:/home/dsmr/app/backups
      - /dev:/dev
    environment:
      - DB_HOST=db-dsmr
      - DSMR_USER=admin
      - DSMR_EMAIL=root@localhost
      - DSMR_PASSWORD=admin
      - VIRTUAL_HOST=localhost
    ports:
      - 8888:80
    network_mode: host      
    devices:
      - /dev/ttyUSB0:/dev/ttyUSB0
ualex73 commented 4 years ago

I cannot see why from the docker container you cannot reach the Mosquitto. This normally should work (docker normally created a NAT from where you can reach the host network and outside world). Only ping isn't the best option, better to use telnet or nc.

When you use "network_mode" the port list cannot be used. So the DSMR-Reader GUI wants to listen on port 192.168.1.32 port 80, which shouldn't be allowed (Synology is listening on it?). If you want to use the "networkhost=8888" you need to modify something in the container (i cannot access my setup, so i cannot give you the filename).

wderuijter commented 4 years ago

When you use "network_mode" the port list cannot be used. So the DSMR-Reader GUI wants to listen on port 192.168.1.32 port 80, which shouldn't be allowed (Synology is listening on it?)

Yeah, that's it :) I'll revert to using the bridge network and debug some more.

wderuijter commented 3 years ago

@ualex73 just to let you know I finally found it, took me a while to find this out :)

The network issue was caused by a setting in Synology's DSM: "Allow multiple gateways". I enabled the option for some VPN stuff. This setting causes a network routing issue with named bridges in docker. After disabling the option all is fine and works like a char,

ualex73 commented 3 years ago

Thanks for the update and it explains the behavior.