Hey,
I am running the latest stable openHAB docker. I use docker-compose
to set it up and it works really great as long as I start the container manually with docker-compose up -d
.
In my compose file I have the option restart: unless-stopped
so the openHAB container should automatically get started upon reboot.
But, the issue comes with my zwave stick /dev/ttyAMC0
, which I have included via devices
in my compose file: Upon reboot the docker-deamon is a couple of seconds faster than the stick resulting in docker not starting the container.
Based on the timestamps in the docker deamon log and dmesg you can clearly see that the device becomes available roughly 7 s later.
journalctl -f -n 100 -u docker.service
Sep 08 19:00:32 nuc dockerd[863]: time="2020-09-08T19:00:32.493077680+02:00" level=error msg="2066fdff0ce6b9590813eda2906c83d409cfe1af9067c629a21103ed7ff0b72a cleanup: failed to delete container from containerd: no such container"
Sep 08 19:00:32 nuc dockerd[863]: time="2020-09-08T19:00:32.493569896+02:00" level=error msg="Failed to start container 2066fdff0ce6b9590813eda2906c83d409cfe1af9067c629a21103ed7ff0b72a: error gathering device information while adding custom device \"/dev/ttyACM0\": no such file or directory"
dmesg -T
[Tue Sep 8 19:00:39 2020] cdc_acm 2-4.4:1.0: ttyACM0: USB ACM device
- Again, I can manually start the container with
docker-compose up -d
so there is no issue with any permissions (dialout group etc.). - If possible I do not want to postpone the whole docker-deamon start (which could easily be done by copying and altering the unit file or even creating a drop-in file) as couple of other containers are started as well, but more important I would like to minimize manipulating a standard docker host. (for me the whole Idea of docker in a private environment is to quickly get stuff up and running, easily backup appdata, move containers around and care not to much about the replaceable host).
I am looking for a solution where I might even (accidentally) unplug the zwave stick and openHAB would start anyways. Preferably, by not creating custom docker images or wrapper scripts where I would loose the convenience of orchestrating all my services with docker compose files.
I know, I am asking for something where so many workarounds exist, but maybe somebody has an idea for a clean solution.
For the sake of completeness my docker compose file:
version: '3'
services:
openhab:
image: "openhab/openhab:latest"
container_name: openhab
restart: always
network_mode: host
volumes:
- "/etc/localtime:/etc/localtime:ro"
- "/etc/timezone:/etc/timezone:ro"
- "${DOCKER_DATA}/openhab/addons:/openhab/addons"
- "${DOCKER_DATA}/openhab/conf:/openhab/conf"
- "${DOCKER_DATA}/openhab/userdata:/openhab/userdata"
- "${DOCKER_DATA}/openhab/cont-init.d:/etc/cont-init.d"
environment:
OPENHAB_HTTP_PORT: "8090"
OPENHAB_HTTPS_PORT: "8443"
EXTRA_JAVA_OPTS: "-Duser.timezone=Europe/Berlin"
USER_ID: 1000
GROUP_ID: 1000
devices:
- "/dev/ttyACM0:/dev/ttyACM0:rwm"
cap_add:
- NET_ADMIN
- NET_RAW