Skip to content

Run in docker‐compose

Volker Hänsel edited this page Oct 5, 2023 · 2 revisions

Docker compose example 1

This is my example of combining the jome automation service with my tuya_mqtt client. In this configuration, the MQTT broker runs in the IP-Symcon service.

version: "3"
services:
  ipsymcon: 
    image: symcon/symcon
    restart: always
    ports:
      - 3777:3777  # IPSYMCON web UI and config port 
      - 1883:1883  # MQTT
    volumes:
      - symcon_data:/var/lib/symcon
      - symcon_log:/var/log/symcon
      - symcon_root:/root

  tuya_mqtt.net:
    image: volkerhaensel/tuya_mqtt.net:latest
    container_name: tuya_mqtt.net
    volumes:
      - tuya.net_config:/app/DataDir  
    environment:
      - ASPNETCORE_URLS=http://+:8889
    ports:
      - 6667:6667/udp #needs to be published to receive encryped TUYA broadcasts 
      - 6666:6666/udp #needs to be published to receive unencryped TUYA broadcasts 
      - 8889:80/tcp #connect to 8889 to get to the web UI
    network_mode: host
    restart: on-failure
#   healthcheck:
#     test: curl --fail http://localhost:8889 || exit 1
#     interval: 60s
#     retries: 5
    
volumes:
  symcon_data:
  symcon_log:
  symcon_root:
  tuya.net_config:

some hints

network_mode: host

this setting is required to get the network broadcast messages into the docker container. Tuya devices broadcast their ID and make them easily identifyable in the network.

This setting will place the container unisolated to the host network adapter.

see Networking using the host network

In case this is not possible or not needed - the devices still can be entered manually by specifying the IP and ID.

directory /app/DataDir

this folder contains the service settings and shall be made persistent

the folde name is case sensitive

healtchcheck

I would advise to deactivate healtchcheck and its associated container restart at the beginning. Healthcheck checks for occuring errors and a disconnected MQTT broker.

see wiki page for details

Docker compose example 2

this docker-compose configuration is my development setup using a mosquitto MQTT broker and a MQTT-explorer to see the published items.

version: '3.4'

services:
  mqtt-explorer:
    image: smeagolworms4/mqtt-explorer
    container_name: mqtt-explorer
    ports:
        - 4000:4000
    volumes:
        - ./mqtt-explorer/config:/mqtt-explorer/config
    networks:
        - mqtt

  mosquitto:
    image: eclipse-mosquitto:2
    container_name: mosquitto
    ports:
        - 1883:1883
        - 8883:8883
        - 9001:9001
    
    volumes:
        - ./mosquitto/config:/mosquitto/config
        - ./mosquitto/data:/mosquitto/data
        - ./mosquitto/log:/mosquitto/log
    networks:
        - mqtt

  tuya_mqtt.net:
    image: volkerhaensel/tuya_mqtt.net
    container_name: tuya_mqtt.net
    volumes:
      - tuya.net_config:/app/DataDir  #DataDir is case sensitive  
    ports:
      - 6667:6667/udp #needs to be published to receive encryped TUYA broadcasts 
      - 6666:6666/udp #needs to be published to receive unencryped TUYA broadcasts 
      - 8889:80/tcp #connect to 8889 to get to the web UI

    restart: on-failure
    healthcheck:
      test: curl --fail http://localhost:80 || exit 1
      interval: 60s
      retries: 5
    networks:
        - mqtt

networks:

  mqtt:
    name: mqtt

volumes:
  tuya.net_config: