Docker Containers, getting killed on LE Reboot/Shutdown

  • Hello,

    As the title is telling, my containers don't gracefully stop which is corrupting files. Mostly .db files go bad on every shutdown.

    How can I fix this. How to gracefully stop all my containers before docker.service is stopped and fs is unmounted? I'm using many of LSIO ones and running them with docker-compose files.

    Regards~

    Edit 1: LE on RK3399.

    Edited once, last by Aciel (February 2, 2022 at 11:12 AM).

  • What you need is to study the linux 'systemd-inhibit' command although I prefer to use commands like 'systemctl mask poweroff.target kodi-poweroff.service' so that no CE/LE device can be powered off.

  • I think your solution is not good, LibreELEC shutdown already does this. I think the problem is in the execution code of the containers that fail because it is not taken into account that they are executed asynchronously in parallel to the execution of LibreELEC, which is the one that has control of the shutdown. For me, I am not a programmer, the solution consists of inserting commands that prevent or delay the shutdown until the most critical phases are completed within the containers.

  • I think your solution is not good, LibreELEC shutdown already does this. I think the problem is in the execution code of the containers that fail because it is not taken into account that they are executed asynchronously in parallel to the execution of LibreELEC, which is the one that has control of the shutdown. For me, I am not a programmer, the solution consists of inserting commands that prevent or delay the shutdown until the most critical phases are completed within the containers.

    Well, i just tested and after using the autostop.sh to stop all containers, my homeassistant container logs no longer complain about the database not being cleanly "closed" .

    Before this, after every restart or shutdown, homeassistant log had at least one entry regarding the database.

    So far the only "downside" is that every container must be set to always restart (obviously, using "unless-stoped" won't restart them upon reboot).