Page 9 of 11

Re: Oficial Docker Container

Posted: Friday 13 January 2023 10:30
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

Re: Oficial Docker Container

Posted: Thursday 19 January 2023 9:39
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.

Re: Oficial Docker Container

Posted: Thursday 19 January 2023 13:34
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.

Re: Oficial Docker Container

Posted: Friday 27 January 2023 19:31
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.

Re: Oficial Docker Container

Posted: Thursday 02 February 2023 12:55
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?

Re: Oficial Docker Container

Posted: Thursday 02 February 2023 13:21
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

Re: Oficial Docker Container

Posted: Thursday 02 February 2023 15:01
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... :)

Re: Oficial Docker Container

Posted: Thursday 02 February 2023 15:24
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".

Re: Oficial Docker Container

Posted: Thursday 02 February 2023 16:55
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.

Re: Oficial Docker Container

Posted: Thursday 02 February 2023 18:14
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?

Re: Oficial Docker Container

Posted: Thursday 02 February 2023 23:47
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?

Re: Oficial Docker Container

Posted: Friday 03 February 2023 8:07
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:

Re: Oficial Docker Container

Posted: Friday 03 February 2023 9:25
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 :)

Re: Oficial Docker Container

Posted: Monday 06 February 2023 14:27
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?

Re: Oficial Docker Container

Posted: Monday 06 February 2023 15:25
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:

Re: Oficial Docker Container

Posted: Tuesday 07 February 2023 11:39
by Nautilus
Sure - will then setup Domoticz in the "old-fashioned" way which luckily is very easy as well :)

Re: Oficial Docker Container

Posted: Thursday 09 February 2023 17:29
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...

Re: Oficial Docker Container

Posted: Thursday 09 February 2023 17:50
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 :)

Re: Oficial Docker Container

Posted: Thursday 09 February 2023 18:17
by nitpicker
Running:

Code: Select all

sudo docker pull portainer/portainer-ce:latest
and nothing happens...

Re: Oficial Docker Container

Posted: Thursday 09 February 2023 18:26
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!