Oficial Docker Container Topic is solved

Subforum for general discussions. Do not dump your questions/problems here, but try to find the subforum where it belongs!

Moderators: leecollings, remb0

User avatar
waltervl
Posts: 5148
Joined: Monday 28 January 2019 18:48
Target OS: Linux
Domoticz version: 2024.7
Location: NL
Contact:

Re: Oficial Docker Container

Post by waltervl »

aukesp wrote: Thursday 12 January 2023 16:12 I try also to use Domoticz on a Docker container and migrate to zwave-JS on a Windows machine with Docker instelled.
Everything is going fine but....
My USB devices are not seen/ connected.
In all packages the note: Like the other methods replace /dev/serial/by-id/insert_stick_reference_here with the serial device for your Z-Wave stick.
Where ever I look i do not find any serial/ USB device.
Also the command: lsusb is not found??
ls -l /dev/ttyUSB0 gives no result.

Where am I going wrong or have I missed something?
You can apperantly use Zwave-JS-UI on windows with an executable you can download from the Zwave-JS-UI releases, no need for Docker. I could not find further instructions so good luck! ;)
https://github.com/zwave-js/zwave-js-ui/releases
Domoticz running on Udoo X86 (on Ubuntu)
Devices/plugins: ZigbeeforDomoticz (with Xiaomi, Ikea, Tuya devices), Nefit Easy, Midea Airco, Omnik Solar, Goodwe Solar
pepsyfantah
Posts: 1
Joined: Thursday 19 January 2023 9:18
Target OS: Raspberry Pi / ODroid
Domoticz version:
Contact:

Re: Oficial Docker Container

Post by pepsyfantah »

Would that be possible to keep the "old" Build of DZ Beta to be able to roll back to a previous docker beta version in case of bugs?
I know I can keep my own dz docker image... but I would feel safer if I can retreive any version.
User avatar
waltervl
Posts: 5148
Joined: Monday 28 January 2019 18:48
Target OS: Linux
Domoticz version: 2024.7
Location: NL
Contact:

Re: Oficial Docker Container

Post by waltervl »

All old builds are stored in Docker Hub so you can always go back to any old version (if a docker build exists). See the instructions on docker hub. See also the tag list in docker hub.
Domoticz running on Udoo X86 (on Ubuntu)
Devices/plugins: ZigbeeforDomoticz (with Xiaomi, Ikea, Tuya devices), Nefit Easy, Midea Airco, Omnik Solar, Goodwe Solar
llbrt
Posts: 1
Joined: Friday 27 January 2023 18:34
Target OS: Linux
Domoticz version: 2022.2
Location: Brittany
Contact:

Re: Oficial Docker Container

Post by llbrt »

Thanks for this great docker image, I used it to build a docker-compose with the MQTT Z-Wave UI. That works fine :D
I've published a GitHub project for a kind of basic generator to create a docker composition that should work out of the box.
Here is almost the link: https: //github com /llbrt/domoticz-docker-mqtt-zw
There are maybe typos or errors, but it should be easy to fix or add more things in the generated elements.
I hope it will be useful.
Nautilus
Posts: 722
Joined: Friday 02 October 2015 12:12
Target OS: Raspberry Pi / ODroid
Domoticz version: beta
Location: Finland
Contact:

Re: Oficial Docker Container

Post by Nautilus »

At the moment I'm running Domoticz in RPi3, no problems. Currently on the same Pi I have zigbee2mqtt, zwavejs2mqtt, mosquitto, lot's of custom python scripts (and python plugins under Domoticz) etc. Also, with the amount of devices growing, size of the Domoticz db growing (been running it from 2015), I feel it will soon start running out of juice. Better disaster recovery etc. would be welcome as well, luckily nothing major happened so far.

Anyhow, the plan is to move everything to a thinclient pc and use Proxmox for virtualization. What I was thinking was to setup virtual machine to run IoTStack (or just install Docker) on latest Debian Bullseye and migrate Domoticz to Docker. And run zigbee2mqtt, zwavejs2mqtt, mosquitto etc. similarly dockerized. But after reading some comments and experiences started to doubt these plans a bit. In domoticz I run several custom scripts with dependencies to different python and other libraries so Docker is probably not the optimal for this?

What would you do in my place - ease of migration being one important consideration on top of futureproof? Would it be better to just install Domoticz on the Debian VM and have a similar setup as I now have on Raspberry / Raspbian? I am already running zwavejs2mqtt in Docker there, zigbee2mqtt should be pretty easy to move to Docker as well. So I could have either one machine specifically for Domoticz and then another VM for Dockers or both Domoticz and Dockers on the same VM? Or is it doable to run Domoticz in Docker as well in my kind of setup?
User avatar
Sjonnie2017
Posts: 361
Joined: Wednesday 02 August 2017 19:43
Target OS: Linux
Domoticz version: Latest ß
Location: The Netherlands
Contact:

Re: Oficial Docker Container

Post by Sjonnie2017 »

Although Waltervl will not agree I am a fan of containerisation since a few months. I had a lot of problems combining a number of applications on my Pi because they were always "fighting" for the same port numbers. So I moved to Docker. I have (amongst others) Domoticz, Dashticz, DeCONZ, Mosquitto running in separate containers and have full control over ports and settings.
I create my Docker containers with docker compose and make sure the persistent volumes are in my home folder somewhere. So in my home folder I have a Domoticz folder with plugins, scripts etc. Just like you would have with a client install.
As an added bonus I have Watchtower monitor my containers and updates them as needed. If I am unhappy with a container I remove it. It leaves absolutely no residu or traces on the host which prevents cluttering up the system over time.
If you are interested I can share some of my Docker compose files with you (anonymised of course).
Migrating from the Pi to your new host is simple. Re-install your plug-ins, copy any custom files over to the host and restore the database. A few minor adjustments and then you'll be up and running. I didn't even have to migrate my scripts because the are all DzVents and Blockly and they are stored in the database.
Note that you will have to set permissions on the Domoticz folder in your home folder so Domoticz can store temporary data there
ConBee II - TRÅDFRI lights + switches, loads of ChingLing dimmers and switches, Heiman and Xiaomi sensors
SolarEdge SE4000H (with active modbus_tcp)
YouLess Energy meter
Shelly 2.5 in roller shutter mode
Nautilus
Posts: 722
Joined: Friday 02 October 2015 12:12
Target OS: Raspberry Pi / ODroid
Domoticz version: beta
Location: Finland
Contact:

Re: Oficial Docker Container

Post by Nautilus »

Sounds good - please do share your docker-compose.yml if not too much trouble. Yes, the volumes should be easy to link to local home, but what I fear is the trickier is the custom scripts that Domoticz should call. They depend on different packages (installed with apt, pip...) which are not probably not automatically visible for Domoticz in a way they would be on "normal" install. Thus the custom start script for docker that I suppose should be used to install them. But maybe that is still a one time effort to get it right and then all will be well after that... :)
User avatar
Sjonnie2017
Posts: 361
Joined: Wednesday 02 August 2017 19:43
Target OS: Linux
Domoticz version: Latest ß
Location: The Netherlands
Contact:

Re: Oficial Docker Container

Post by Sjonnie2017 »

I installed the plugins on the host in the Domoticz folder. Some used a shell script others use pip(3). All working as expected. The docker-compose.yml on my machine is located in ~/containers/domoticz. I create a persistent volume data in that folder to store the data for the container.

Code: Select all

version: '3.3'

services:
  domoticz:
    image: domoticz/domoticz
    container_name: domoticz
    restart: unless-stopped
    # Pass devices to container
    # devices:
    #   - "/dev/serial/by-id/usb-0658_0200-if00:/dev/ttyACM0"
    ports:
      - "12080:8080"
      - "2443:443"
    volumes:
      - ./data:/opt/domoticz/userdata
    environment:
      - TZ=Europe/Amsterdam
      #- LOG_PATH=/opt/domoticz/userdata/domoticz.log
I use 12080 because the port was already "taken".
ConBee II - TRÅDFRI lights + switches, loads of ChingLing dimmers and switches, Heiman and Xiaomi sensors
SolarEdge SE4000H (with active modbus_tcp)
YouLess Energy meter
Shelly 2.5 in roller shutter mode
User avatar
waltervl
Posts: 5148
Joined: Monday 28 January 2019 18:48
Target OS: Linux
Domoticz version: 2024.7
Location: NL
Contact:

Re: Oficial Docker Container

Post by waltervl »

Sjonnie2017 wrote: Thursday 02 February 2023 13:21 Although Waltervl will not agree I am a fan of containerisation since a few months.
:) It is your Domoticz environment! :)
I have a very simple environment: Domoticz and a couple of Python plugins. No MQTT, no dashticz etc. But in your environment I can understand containerizing although every application has settings for ports to prevent conficts.
Domoticz running on Udoo X86 (on Ubuntu)
Devices/plugins: ZigbeeforDomoticz (with Xiaomi, Ikea, Tuya devices), Nefit Easy, Midea Airco, Omnik Solar, Goodwe Solar
User avatar
Sjonnie2017
Posts: 361
Joined: Wednesday 02 August 2017 19:43
Target OS: Linux
Domoticz version: Latest ß
Location: The Netherlands
Contact:

Re: Oficial Docker Container

Post by Sjonnie2017 »

I was just kidding you! :mrgreen: The really great part is that Domoticz provides a solution for all environments. So I have a choice and how cool is that?
ConBee II - TRÅDFRI lights + switches, loads of ChingLing dimmers and switches, Heiman and Xiaomi sensors
SolarEdge SE4000H (with active modbus_tcp)
YouLess Energy meter
Shelly 2.5 in roller shutter mode
Nautilus
Posts: 722
Joined: Friday 02 October 2015 12:12
Target OS: Raspberry Pi / ODroid
Domoticz version: beta
Location: Finland
Contact:

Re: Oficial Docker Container

Post by Nautilus »

Sjonnie2017 wrote: Thursday 02 February 2023 15:24 I installed the plugins on the host in the Domoticz folder. Some used a shell script others use pip(3). All working as expected. The docker-compose.yml on my machine is located in ~/containers/domoticz. I create a persistent volume data in that folder to store the data for the container.

Code: Select all

version: '3.3'

services:
  domoticz:
    image: domoticz/domoticz
    container_name: domoticz
    restart: unless-stopped
    # Pass devices to container
    # devices:
    #   - "/dev/serial/by-id/usb-0658_0200-if00:/dev/ttyACM0"
    ports:
      - "12080:8080"
      - "2443:443"
    volumes:
      - ./data:/opt/domoticz/userdata
    environment:
      - TZ=Europe/Amsterdam
      #- LOG_PATH=/opt/domoticz/userdata/domoticz.log
I use 12080 because the port was already "taken".
Thanks, this is excellent :) So all of your Domoticz config files are in ~/containers/domoticz/data -> i.e. domoticz.db and various subfolders like scripts, www, plugins, Config etc? And by Plugins you mean the ones that in standard install are under domoticz/Plugins? In my case, I have a lot of scripts under domoticz/scripts/, bash, python, node etc. (using libraries that are installed with apt or pip) which need to be called by Domoticz. Assuming the containerized Domoticz sees only the content of its container - and then of course what is in the linked persistent volume - it cannot out of the box run these scripts if e.g. node, jq, etc. would only be installed on the host machine? These would also need to be installed to the container and that is why there is the custom startup script: https://www.domoticz.com/wiki/Docker#cu ... _container
The container supports running a custom bash script (customstart.sh in userdata) before the domoticz process starts. This way, you can customise anything in the container that you need:

install incremental apt packages (don't forget to apt update before you apt install)
install incremental python functions (pip3 install)
and so on
But you don't depend on any additional stuff configured in the startup script?
User avatar
Sjonnie2017
Posts: 361
Joined: Wednesday 02 August 2017 19:43
Target OS: Linux
Domoticz version: Latest ß
Location: The Netherlands
Contact:

Re: Oficial Docker Container

Post by Sjonnie2017 »

No, I don't depend on the startup script! I do have a Mosquitto container which I use for ShellyMQTT plugin. I had a node red container but didn't use that much so I deleted that. I do remember that I had to install a python library "in" Domoticz using pip3. But the library is saved in the persistent volume (data) and I can savely update the container. For reference you can read the ShellyMQTT plugin thread on this forum.

I do think that your scripts will run (well... most of them anyway ;)) but I can understand your uncertanty in this matter. If you happen to have an old computer lying around, you could do a test. I know I did for my first container experiment :mrgreen:
ConBee II - TRÅDFRI lights + switches, loads of ChingLing dimmers and switches, Heiman and Xiaomi sensors
SolarEdge SE4000H (with active modbus_tcp)
YouLess Energy meter
Shelly 2.5 in roller shutter mode
Nautilus
Posts: 722
Joined: Friday 02 October 2015 12:12
Target OS: Raspberry Pi / ODroid
Domoticz version: beta
Location: Finland
Contact:

Re: Oficial Docker Container

Post by Nautilus »

Yeah, have been using docker for a while now, e.g. zwajejs2mqtt, vscode, ftp-server, homeassistant etc. but with these it is sort of more clear what is containeraized. In Domoticz, if I for example call script from a switch with

Code: Select all

script:///path
and this script is then using some library that is installed on the host machine, I imagine the potential trouble starts. But I have the Proxmox now running on the thinclient and will start testing with Debian VM + Docker how it goes. Thanks for the help so far :)
Nautilus
Posts: 722
Joined: Friday 02 October 2015 12:12
Target OS: Raspberry Pi / ODroid
Domoticz version: beta
Location: Finland
Contact:

Re: Oficial Docker Container

Post by Nautilus »

Did some testing now and indeed it looks a bit worrying for the future. I first tested with some simple os.execute('curl...) in lua and that worked fine. Then I wanted to try a bash script that uses wget to store a snapshot of security camera and send it via telegram (curl). With this I was already lost that where does the file go if I drop it to the persistent volume ./domoticz/scripts/. Eventually I realized it was under /opt/domoticz/userdata/scripts - now I was able to finally call it.

It called it without errors, but nothing happened. So I logged to docker console and run it and found that pgrep and wget are not installed. After some apt update && apt upgrade I was able to apt install them and finally run the script succesfully.

But I did not see anything created in persistent data folder (ref: "I do remember that I had to install a python library "in" Domoticz using pip3. But the library is saved in the persistent volume (data) and I can savely update the container.") so after recreating the container it was back to start with wget and pgrep missing. I guess with the startup scripts I could get around this.

But all in all, it seems like quite a big effort to move from what I have now to Docker. Doable, I'm sure - but a lot of reconfiguring, a huge startup script (I fear) etc. Not maybe worth the effort.

Or - do you think I've missed something here, done something wrong in setting up the Docker container? Or some benefit I am not seeing?
User avatar
Sjonnie2017
Posts: 361
Joined: Wednesday 02 August 2017 19:43
Target OS: Linux
Domoticz version: Latest ß
Location: The Netherlands
Contact:

Re: Oficial Docker Container

Post by Sjonnie2017 »

No, you haven't missed anything. From what I read I can safely say your use case does not match with a containerised Domoticz. The amount of external software/scripts is bigger and more complex than I could imagine.

As for disaster recovery: i have a "spare" server lying on the shelf. If need be I can have it fully up and running in half an hour (I unwillingly tested that yesterday ;) ). Or create a disk image with dd every night and an rsync of your homefolder (with all your configuration files and Domoticz database) to a NAS (i.e.) at noon. It's simple but it works. :mrgreen:
ConBee II - TRÅDFRI lights + switches, loads of ChingLing dimmers and switches, Heiman and Xiaomi sensors
SolarEdge SE4000H (with active modbus_tcp)
YouLess Energy meter
Shelly 2.5 in roller shutter mode
Nautilus
Posts: 722
Joined: Friday 02 October 2015 12:12
Target OS: Raspberry Pi / ODroid
Domoticz version: beta
Location: Finland
Contact:

Re: Oficial Docker Container

Post by Nautilus »

Sure - will then setup Domoticz in the "old-fashioned" way which luckily is very easy as well :)
nitpicker
Posts: 69
Joined: Tuesday 29 July 2014 10:05
Target OS: Raspberry Pi / ODroid
Domoticz version: 2022.2
Contact:

Re: Oficial Docker Container

Post by nitpicker »

I don't know why, but I cannot start containers.

I installed Raspberry Pi OS (64-bit) on a hard drive and connected it to a Raspberry Pi 4.
Updated the OS.
Installed docker compose via:

Code: Select all

 sudo curl -SL https://github.com/docker/compose/releases/download/v2.16.0/docker-compose-linux-aarch64 -o /usr/local/bin/docker-compose

Code: Select all

chmod +x /usr/local/bin/docker-compose
When I run docker-compose I get the usage information. So, I guess, docker-compose works fine.

Code: Select all

mkdir /opt/domoticz
cd /opt/domoticz
docker-compose.yml

Code: Select all

version: '3.3'

services:
  domoticz:
    image: domoticz/domoticz:stable
    container_name: domoticz
    restart: unless-stopped
    # Pass devices to container
    # devices:
    #   - "/dev/serial/by-id/usb-0658_0200-if00-port0:/dev/ttyACM0"
    ports:
      - "8080:8080"
    volumes:
      - ./config:/opt/domoticz/userdata
    environment:
      - TZ=Europe/Amsterdam
      #- LOG_PATH=/opt/domoticz/userdata/domoticz.log

Code: Select all

sudo chmod +x docker-compose.yml

Code: Select all

sudo docker-compose up -d
(without sudo it doesn't run: permission denied)

and then it is silent...
User avatar
Sjonnie2017
Posts: 361
Joined: Wednesday 02 August 2017 19:43
Target OS: Linux
Domoticz version: Latest ß
Location: The Netherlands
Contact:

Re: Oficial Docker Container

Post by Sjonnie2017 »

Try installing Portainer to see if the container is created. There are other ways of finding out if a container is created but this is (for me) the most elegant and simple one :)
ConBee II - TRÅDFRI lights + switches, loads of ChingLing dimmers and switches, Heiman and Xiaomi sensors
SolarEdge SE4000H (with active modbus_tcp)
YouLess Energy meter
Shelly 2.5 in roller shutter mode
nitpicker
Posts: 69
Joined: Tuesday 29 July 2014 10:05
Target OS: Raspberry Pi / ODroid
Domoticz version: 2022.2
Contact:

Re: Oficial Docker Container

Post by nitpicker »

Running:

Code: Select all

sudo docker pull portainer/portainer-ce:latest
and nothing happens...
User avatar
Sjonnie2017
Posts: 361
Joined: Wednesday 02 August 2017 19:43
Target OS: Linux
Domoticz version: Latest ß
Location: The Netherlands
Contact:

Re: Oficial Docker Container

Post by Sjonnie2017 »

Please go to the Portainer website and follow instructions. You need to create a volume (docker volume create portainer_data) and then pull the image with the correct options (https://docs.portainer.io/start/install ... cker/linux)

Good luck!
ConBee II - TRÅDFRI lights + switches, loads of ChingLing dimmers and switches, Heiman and Xiaomi sensors
SolarEdge SE4000H (with active modbus_tcp)
YouLess Energy meter
Shelly 2.5 in roller shutter mode
Post Reply

Who is online

Users browsing this forum: No registered users and 1 guest