Using Docker and userscripts (Lua, DzVents, Python) Topic is solved

On various Hardware and OS systems: pi / windows / routers / nas, etc

Moderator: leecollings

User avatar
waaren
Posts: 6028
Joined: Tuesday 03 January 2017 14:18
Target OS: Linux
Domoticz version: Beta
Location: Netherlands
Contact:

Re: Using Docker and userscripts (Lua, DzVents, Python)

Post by waaren »

knireis wrote: Thursday 29 April 2021 11:45 2021-04-29 11:42:14.346 Error: EventSystem: problem writing file: /opt/domoticz/userdata/scripts/dzVents/generated_scripts/linphone-init.lua

Seems to be an access issue?
Yes.

I do not use docker yet so cannot advise but would it possible to manually create this folder in the docker env. and set the rights in such a way that domoticz can write these scripts?
Debian buster, bullseye on RPI-4, Intel NUC.
dz Beta, Z-Wave, RFLink, RFXtrx433e, P1, Youless, Hue, Yeelight, Xiaomi, MQTT
==>> dzVents wiki
Gravityz
Posts: 583
Joined: Wednesday 16 December 2015 19:13
Target OS: NAS (Synology & others)
Domoticz version: 2022.2
Location: Netherlands
Contact:

Re: Using Docker and userscripts (Lua, DzVents, Python)

Post by Gravityz »

did you check if that directory path exists on your pi
i found that it is not so much a rights issue but wether the directory exists.
domoticz can create/write the file but does not create the directories if they do not exist.

path on your pi which you mapped to /opt/docker
****/docker/domoticz

directory path which needs to exist
****/docker/domoticz/scripts/dzVents/generated_script
****/docker/domoticz/scripts/dzVents/scripts

so manually create those directories
knireis
Posts: 16
Joined: Wednesday 09 April 2014 14:44
Target OS: Raspberry Pi / ODroid
Domoticz version:
Contact:

Re: Using Docker and userscripts (Lua, DzVents, Python)

Post by knireis »

you are right, the directories did not exist (i use a QNAP).
I created them and now the script starts.
Gravityz
Posts: 583
Joined: Wednesday 16 December 2015 19:13
Target OS: NAS (Synology & others)
Domoticz version: 2022.2
Location: Netherlands
Contact:

Re: Using Docker and userscripts (Lua, DzVents, Python)

Post by Gravityz »

good to hear.
i am still not switched over to the docker version but decided some time a go to test it.
every problem i have discovered sofar(JSON file not existing, script errrors, script directory mappings) have been fixed .

still need to figur out if serial drivers on my synology will inteferee with the current package
knireis wrote: Thursday 29 April 2021 13:09 you are right, the directories did not exist (i use a QNAP).
I created them and now the script starts.
User avatar
waltervl
Posts: 5149
Joined: Monday 28 January 2019 18:48
Target OS: Linux
Domoticz version: 2024.7
Location: NL
Contact:

Re: Using Docker and userscripts (Lua, DzVents, Python)

Post by waltervl »

Gravityz wrote: Thursday 29 April 2021 13:06 directory path which needs to exist
****/docker/domoticz/scripts/dzVents/generated_script
****/docker/domoticz/scripts/dzVents/scripts

so manually create those directories
Is this something that can be done with the Docker composer file so you do not have to do this everytime you update the Domoticz docker image?
Or will updating the Domoticz docker leave this untouched?
Domoticz running on Udoo X86 (on Ubuntu)
Devices/plugins: ZigbeeforDomoticz (with Xiaomi, Ikea, Tuya devices), Nefit Easy, Midea Airco, Omnik Solar, Goodwe Solar
knireis
Posts: 16
Joined: Wednesday 09 April 2014 14:44
Target OS: Raspberry Pi / ODroid
Domoticz version:
Contact:

Re: Using Docker and userscripts (Lua, DzVents, Python)

Post by knireis »

you don't need to do this everytime
you map the drive location to a folder on the host so it is persistent when you upgrade or reinstall the docker

in my case i had to create the specified folders on the host
dens1975
Posts: 26
Joined: Monday 12 February 2018 17:03
Target OS: NAS (Synology & others)
Domoticz version:
Contact:

Re: Using Docker and userscripts (Lua, DzVents, Python)

Post by dens1975 »

I recently moved from the Jadahl package to the docker container. I still having some issues with bash scripts. They are executed and when I look in the docker terminal I see the reason is: wget: not found

So what am I missing here? wget should be installed by default? Or is it some reference somewhere?

Hope someone can point me in the right direction.
pvklink
Posts: 822
Joined: Wednesday 12 November 2014 15:01
Target OS: Raspberry Pi / ODroid
Domoticz version: latest b
Contact:

Re: Using Docker and userscripts (Lua, DzVents, Python)

Post by pvklink »

You can login into the docker container and execute wget in the container to check if the command is installed....

sudo docker exec -it domoticz wget

or

sudo docker exec -it domoticz/bin/bash
then: wget
exit
Raspberry (raspbian on rpi 3) , Domoticz Beta, dzVents , RFXtrx433e, P1, Hue, Yeelight, Zwave+, X10, ESP(easy), MQTT,Weather Underground, System Alive Checker, Domoticz Remote Server to RPI with Google Assistant,
Jablotron connection, Ikea
dens1975
Posts: 26
Joined: Monday 12 February 2018 17:03
Target OS: NAS (Synology & others)
Domoticz version:
Contact:

Re: Using Docker and userscripts (Lua, DzVents, Python)

Post by dens1975 »

pvklink wrote: Monday 07 February 2022 23:07 You can login into the docker container and execute wget in the container to check if the command is installed....

sudo docker exec -it domoticz wget

or

sudo docker exec -it domoticz/bin/bash
then: wget
exit
Thanks, tried both and first says: OCI runtime exec failed: exec failed: container_linux.go:367: starting container process caused: exec: "wget": executable file not found in $PATH: unknown

second command: wget: command not found

Found command somewhere: apt-get install -y wget
Executed from terminal in docker container

Now it works again! Solved.
Last edited by dens1975 on Tuesday 08 February 2022 13:56, edited 1 time in total.
User avatar
waltervl
Posts: 5149
Joined: Monday 28 January 2019 18:48
Target OS: Linux
Domoticz version: 2024.7
Location: NL
Contact:

Re: Using Docker and userscripts (Lua, DzVents, Python)

Post by waltervl »

Open Docker on your Synology, go to the Domoticz container, select Details, Terminal, and open 'bash'.

Code: Select all

apt-get update
apt-get install wget
It perhaps is needed to use 'sudo' in front of these commands.
Domoticz running on Udoo X86 (on Ubuntu)
Devices/plugins: ZigbeeforDomoticz (with Xiaomi, Ikea, Tuya devices), Nefit Easy, Midea Airco, Omnik Solar, Goodwe Solar
Emax
Posts: 11
Joined: Wednesday 23 August 2017 10:39
Target OS: NAS (Synology & others)
Domoticz version:
Contact:

Re: Using Docker and userscripts (Lua, DzVents, Python)

Post by Emax »

Experimenting further with scripts on the official docker image i notice that blocky scripts are generated ok but on the dzvents part it fails with:

Code: Select all

 2021-03-18 21:19:18.108 Status: dzVents: Write file: /opt/domoticz/userdata/scripts/dzVents/generated_scripts/Script #2.lua
2021-03-18 21:19:18.108 Error: EventSystem: problem writing file: /opt/domoticz/userdata/scripts/dzVents/generated_scripts/Script #2.lua 
i suspect this is because of a issue with read/writing rights in the container.
I tried to set the correct rights through putty with:

Code: Select all

docker exec -it DomoTest chmod -R 777  /opt/domoticz/userdata/
Just moved from docker container Linuxserver/Domotiz 2020.2 version to official Domoticz docker 2022.1 and got the exact same problem. Creating the directories solved the issue, but the root cause seems to be that the container creates the scripts-directory in /opt/domiticz/scripts/, while Domoticz expects it to be at /opt/domoticz/userdata/scripts/

So it seems to be an issue with creation of the container. Was this already adresses somewhere?
Gravityz
Posts: 583
Joined: Wednesday 16 December 2015 19:13
Target OS: NAS (Synology & others)
Domoticz version: 2022.2
Location: Netherlands
Contact:

Re: Using Docker and userscripts (Lua, DzVents, Python)

Post by Gravityz »

You need to mount /opt/domoticz/userdata to a directory outside of the container
once you do that the script directory under userdata is used
after that manually(only once) create the following directories to that place

in my case
i mounted external directory domoticz/docker to /op/domoticz/userdata

after that i created on my synology

/volume1/docker/domoticz/scripts/dzVents/generated_scripts
/volume1/docker/domoticz/scripts/dzVents/scripts
/volume1/docker/domoticz/scripts/logrotate
/volume1/docker/domoticz/scripts/templates




Emax wrote: Thursday 10 March 2022 13:32 Experimenting further with scripts on the official docker image i notice that blocky scripts are generated ok but on the dzvents part it fails with:

Code: Select all

 2021-03-18 21:19:18.108 Status: dzVents: Write file: /opt/domoticz/userdata/scripts/dzVents/generated_scripts/Script #2.lua
2021-03-18 21:19:18.108 Error: EventSystem: problem writing file: /opt/domoticz/userdata/scripts/dzVents/generated_scripts/Script #2.lua 
i suspect this is because of a issue with read/writing rights in the container.
I tried to set the correct rights through putty with:

Code: Select all

docker exec -it DomoTest chmod -R 777  /opt/domoticz/userdata/
Just moved from docker container Linuxserver/Domotiz 2020.2 version to official Domoticz docker 2022.1 and got the exact same problem. Creating the directories solved the issue, but the root cause seems to be that the container creates the scripts-directory in /opt/domiticz/scripts/, while Domoticz expects it to be at /opt/domoticz/userdata/scripts/

So it seems to be an issue with creation of the container. Was this already adresses somewhere?
[/quote]
Emax
Posts: 11
Joined: Wednesday 23 August 2017 10:39
Target OS: NAS (Synology & others)
Domoticz version:
Contact:

Re: Using Docker and userscripts (Lua, DzVents, Python)

Post by Emax »

Gravityz wrote: Thursday 10 March 2022 13:45 You need to mount /opt/domoticz/userdata to a directory outside of the container
once you do that the script directory under userdata is used
after that manually(only once) create the following directories to that place

in my case
i mounted external directory domoticz/docker to /op/domoticz/userdata

after that i created on my synology

/volume1/docker/domoticz/scripts/dzVents/generated_scripts
/volume1/docker/domoticz/scripts/dzVents/scripts
/volume1/docker/domoticz/scripts/logrotate
/volume1/docker/domoticz/scripts/templates
This is about fixing the issue, I wonder about what is causing the issue. Why are those directories not created when installing the container? And why do I have and /opt/domoticz/scripts with has all the directories that are missing under /opt/domoticz/userdata/scripts, while these directories are not used from /opt/domoticz/scripts. To me that sounds like the scripts directory was created in an incorrect folder when installing the docker container.
Gravityz
Posts: 583
Joined: Wednesday 16 December 2015 19:13
Target OS: NAS (Synology & others)
Domoticz version: 2022.2
Location: Netherlands
Contact:

Re: Using Docker and userscripts (Lua, DzVents, Python)

Post by Gravityz »

i think this is by design.
it is not an error like you think it is.

you can install the container and put your scripts and the database in the default directory.
as far as i can tell this works.(this is the reason the default directories are created inside the container)
problem however it that every time you upgrade the container you need to move all the custom files to inside the container.
this is why most container support the ability to mount an external directory to an internal mountpoint.
this way you only need to upgrade the container and everrything(database, scripts etc) stays outside the container but mapped to the internal directory of that container.

now why do we not create those external directories, easy everybody has different systems(pi,synology,pc) and is using different directories and mountpoints.
you can not create such a thing because it depends on the platform.

the minute i found out that i could solve the problem by creating external directories i did. I then tried to automate this but since it was only necessary the first time i stopped.
i made myself a really good readme so that i know how to install, upgrade and downgrade the domoticz container without loosing data

hopefully things are clear now and if i misunderstood your problem then hopefully somebody else can answer it.
sammyke007
Posts: 204
Joined: Monday 08 May 2017 20:48
Target OS: Raspberry Pi / ODroid
Domoticz version: 2022.1
Location: Belgium
Contact:

Re: Using Docker and userscripts (Lua, DzVents, Python)

Post by sammyke007 »

waltervl wrote: Tuesday 08 February 2022 13:52 Open Docker on your Synology, go to the Domoticz container, select Details, Terminal, and open 'bash'.

Code: Select all

apt-get update
apt-get install wget
It perhaps is needed to use 'sudo' in front of these commands.
I'm going to switch to a Dockered Domoticz and I need wget, jq and oathtool for scripts. This does indeed work, but I guess this installs inside the container so you'll have to run command after each update / container recreation, correct?

Is it possible to edit the "official" dockerfile so you can pass extra packages as an environment variable?
User avatar
waltervl
Posts: 5149
Joined: Monday 28 January 2019 18:48
Target OS: Linux
Domoticz version: 2024.7
Location: NL
Contact:

Re: Using Docker and userscripts (Lua, DzVents, Python)

Post by waltervl »

Yes, you have to install this every time you update your container

I stopped with docker but I know there was some discussion about this topic on the forum. But no real solution.
Domoticz running on Udoo X86 (on Ubuntu)
Devices/plugins: ZigbeeforDomoticz (with Xiaomi, Ikea, Tuya devices), Nefit Easy, Midea Airco, Omnik Solar, Goodwe Solar
sammyke007
Posts: 204
Joined: Monday 08 May 2017 20:48
Target OS: Raspberry Pi / ODroid
Domoticz version: 2022.1
Location: Belgium
Contact:

Re: Using Docker and userscripts (Lua, DzVents, Python)

Post by sammyke007 »

Ok, that's what I taught indeed. May I ask what type of installation you prefer now?
I'm running Proxmox with a VM for HASS OS and an LXC container for my Docker containers (zigbee2mqtt, zwavejs2mqtt, mosquitto, ...). Do you use a full VM for Domoticz?
User avatar
waltervl
Posts: 5149
Joined: Monday 28 January 2019 18:48
Target OS: Linux
Domoticz version: 2024.7
Location: NL
Contact:

Re: Using Docker and userscripts (Lua, DzVents, Python)

Post by waltervl »

I use a x86 board running Ubuntu. Only function is Domoticz so no need to use docker or VM.
Domoticz running on Udoo X86 (on Ubuntu)
Devices/plugins: ZigbeeforDomoticz (with Xiaomi, Ikea, Tuya devices), Nefit Easy, Midea Airco, Omnik Solar, Goodwe Solar
Post Reply

Who is online

Users browsing this forum: No registered users and 1 guest