fbacker / broadlink-mqtt-bridge

Bridge Broadlink RM Devices with MQTT and API for e.g. OpenHAB
41 stars 14 forks source link

Updated and polished Dockerfile #32

Closed daFritz84 closed 4 years ago

daFritz84 commented 4 years ago

I gave some love to the existing Dockerfile:

I also added a docker_build shell script. Not really necessary, but it saves precious typing time.

Tried and tested on my local Intel NUC.

CBrosius commented 4 years ago

Works fine. I build a custom docker-image based on that with MultiArch-Support for ARM32/ARM64

fbacker commented 4 years ago

thanks @daFritz84

did some more modifications. hope I didn't mess it up. How do you run it??? I can't find the broadlink device when scanning.

/config = if you using a local.json config file /commands = where to place the commands

docker run --rm -it -v /Users/backer/Work/broadlink-mqtt-bridge/commands:/commands -v /Users/backer/Work/broadlink-mqtt-bridge/test:/config -p 3000:3000/tcp -p 3001:3001/tcp fredrickbacker/broadlink-mqtt-bridge:latest
CBrosius commented 4 years ago

I created a macvlan-bridge an use a dedicated IP for the mqttbridge. Then autodiscovery is working fine.

daFritz84 commented 4 years ago

Hi,

try adding the --net=host to your command.

I run into the same problem when first trying out your service with docker and scratched my head for a bit. Until I realized that the local IP is used to determine the IP scan range and docker, of course, creates a software defined network separated from the host for its containers. So if you want the IP address of the docker host (i.e., the machine you are running docker on) to be visible to your container you have to enable 'host mode'.

Btw., here is a snippet from my docker-compose file as reference:

  broadlink2mqtt:
    container_name: broadlink2mqtt
    image: broadlink-mqtt-bridge:latest
    restart: unless-stopped
    volumes:
      - /opt/broadlink2mqtt/config:/broadlink-mqtt-bridge/config
      - /opt/broadlink2mqtt/commands:/broadlink-mqtt-bridge/commands
    network_mode: "host"
    ports:
      - 3000:3000
      - 3001:3001
fbacker commented 4 years ago

tried running host docker run --rm -it -v /Users/backer/Work/broadlink-mqtt-bridge/commands:/commands --net=host fredrickbacker/broadlink-mqtt-bridge:latestbut then I can't access localhost:3000. Remember I've some issues with this before but don't know how I sovled it. only using host would be easiest solution than adding special networking

daFritz84 commented 4 years ago

localhost won't work, since docker does not bind to 127.0.0.1 on the host machine (as far as I remember). Try the external ip of the host machine, e.g. http://192.168.194.46:3000/

fbacker commented 4 years ago

Cheers, loaded up on the ubuntu in the basement, running and finding. Will update the docs. Thanks for the help.