Docker system.d service not working (domoticz)

  • Hello I am trying to run domoticz on boot as a docker container, so I have the following "domoticz.service" file in /storage/.config/system.d

    After a reboot the domoticz container starts (I can see it running from "docker ps" command), but after some seconds it suddenly stops. If I enable the parameter "Restart" to "Allways" the docker container keeps starting and stopping in a loop.

    If I check the container logs with the command "docker logs domoticz", I get the following:

    If I run the ExecStart command manually it works perfectly. What is wrong?

    Thanks!

  • Hello I am trying to run domoticz on boot as a docker container, so I have the following "domoticz.service" file in /storage/.config/system.d

    After a reboot the domoticz container starts (I can see it running from "docker ps" command), but after some seconds it suddenly stops. If I enable the parameter "Restart" to "Allways" the docker container keeps starting and stopping in a loop.

    If I check the container logs with the command "docker logs domoticz", I get the following:

    If I run the ExecStart command manually it works perfectly. What is wrong?

    Thanks!

    Why don't you use the docker addon?

  • It starts for me fine. What was the command to create domoticz container?

    Code
    docker create --name=domoticz -e PUID=0 -e PGID=0 -e TZ=Europe/Madrid -p 7070:8080 -p 6144:6144 -p 7443:1443 -v /storage/domoticz/:/config --device /dev/ttyACM0:/dev/ttyACM0 --restart unless-stopped linuxserver/domoticz
  • Why don't you use the docker addon?

    I am using docker as an addon, installed from Libreelec repository (service.system.docker).

    I have found that there is a domoticz addon from Linuxserver repository, but I feel more confident managing docker from the command line.

  • When creating docker try without --restart unless-stopped.

    I have created the docker container removing that parameter but nothing changes.

    It seems that domoticz is started but then somehow it exits/gets killed.

    If I run the command "systemct start domoticz.service" and just after that I run "systemctl status domoticz" I get the following:

    Code
    ● domoticz.service - Domoticz Container
    Loaded: loaded (/storage/.config/system.d/domoticz.service; enabled; vendor preset: disabled)
    Active: active (running) since Wed 2019-05-22 10:24:01 CEST; 1s ago
    Process: 1998 ExecStop=/storage/.kodi/addons/service.system.docker/bin/docker stop domoticz (code=exited, status=0/SUCCESS)
    Main PID: 2274 (docker)
    Memory: 5.2M
    CGroup: /system.slice/domoticz.service
    └─2274 /storage/.kodi/addons/service.system.docker/bin/docker start domoticz
    
    May 22 10:24:01 kodi systemd[1]: Started Domoticz Container.

    Just after that one I run the same command and I get:

    And if I run the same command again:

    Code
    ● domoticz.service - Domoticz Container
    Loaded: loaded (/storage/.config/system.d/domoticz.service; enabled; vendor preset: disabled)
    Active: inactive (dead) since Wed 2019-05-22 10:25:09 CEST; 2s ago
    Process: 2889 ExecStop=/storage/.kodi/addons/service.system.docker/bin/docker stop domoticz (code=exited, status=0/SUCCESS)
    Process: 2716 ExecStart=/storage/.kodi/addons/service.system.docker/bin/docker start domoticz (code=exited, status=0/SUCCESS)
    Main PID: 2716 (code=exited, status=0/SUCCESS)
    
    May 22 10:25:06 kodi systemd[1]: Started Domoticz Container.
    May 22 10:25:07 kodi docker[2716]: domoticz
    May 22 10:25:09 kodi docker[2889]: domoticz

    And domoticz container is not running ("docker ps -a"):

    Code
    CONTAINER ID        IMAGE                  COMMAND             CREATED             STATUS                     PORTS               NAMES
    c7cf291ef6b6        linuxserver/domoticz   "/init"             15 minutes ago      Exited (0) 5 minutes ago                       domoticz


    What can I do?

    Thanks!

  • After you create domoticz container do you run it from console to initialize it? Because I can run it just fine.

    Code
    docker start domoticz
    
    # look if completely started with
    docker logs domoticz
  • After you create domoticz container do you run it from console to initialize it? Because I can run it just fine.

    Code
    docker start domoticz
    
    # look if completely started with
    docker logs domoticz

    Yes, after creating the container I run for the first time with "docker start domoticz".

    Later, anytime I run from the console with "docker start domoticz" it works perfectly, that is why I do not know why is not working as a service.

  • Then I can't help you anymore. I only create container and for me it runs fine after reboot too.

    And how did you managed to run after reboot? autostart.sh or systemd.d? Can you share the contents of your system.d service file for domoticz?

  • Try with this Start and Stop:

    Code
    ExecStart=/storage/.kodi/addons/service.system.docker/bin/docker start -a domoticz
    ExecStop=/storage/.kodi/addons/service.system.docker/bin/docker stop -t 2 domoticz
  • Try with this Start and Stop:

    Code
    ExecStart=/storage/.kodi/addons/service.system.docker/bin/docker start -a domoticz
    ExecStop=/storage/.kodi/addons/service.system.docker/bin/docker stop -t 2 domoticz

    Yes, now it is wroking! Do you have any explanation for that? :S

    Thanks anyway!

  • Do you have any explanation for that? :S

    No actually. I just look around how other docker services are started and saw this small change. Maybe

    Code
    --attach , -a Attach STDOUT/STDERR and forward signals
    -t, --time int Seconds to wait for stop before killing it (default 10)