- Platform information:
- Hardware: Intel Core i5 / 16GB RAM/ 500GB SSD
- OS: Ubuntu 18.04.3 LTS
- Java Runtime Environment: N/A - docker container
- openHAB container version: openhab/openhab:milestone (i.e. 2.5.0)
I’m having trouble getting systemd to manage my OpenHAB container. If I start the container using the command line below, it works fine.
docker run --name openhab \
--net=home-lan \
--ip=192.168.1.63 \
-v /etc/localtime:/etc/localtime:ro \
-v /etc/timezone:/etc/timezone:ro \
-v openhab_addons:/openhab/addons \
-v openhab_conf:/openhab/conf \
-v openhab_userdata:/openhab/userdata \
--device=/dev/ttyACM0 \
-e CRYPTO_POLICY=unlimited \
-e "EXTRA_JAVA_OPTS=-Duser.timezone=Australia/Sydney" \
--restart=always \
-d openhab/openhab:milestone
However, when I try to start the container using systemd and the openhab.service file below, it fails.
[Unit]
Description=openHAB
Requires=docker.service
Wants=influxdb.service
After=docker.service influxdb.service
[Service]
Restart=always
ExecStart=/usr/bin/docker run --name=%n \
--net=home-lan \
--ip=192.168.1.63 \
-v /etc/localtime:/etc/localtime:ro \
-v /etc/timezone:/etc/timezone:ro \
-v openhab_addons:/openhab/addons \
-v openhab_conf:/openhab/conf \
-v openhab_userdata:/openhab/userdata \
--device=/dev/ttyACM0 \
-e CRYPTO_POLICY=unlimited \
-e "EXTRA_JAVA_OPTS=-Duser.timezone=Australia/Sydney" \
openhab/openhab:milestone
ExecStop=/usr/bin/docker stop -t 2 %n ; /usr/bin/docker rm -f %n
[Install]
WantedBy=multi-user.target
The error code doesn’t really give me a whole lot to go on.
jon@master:/etc/systemd/system$ sudo systemctl status openhab
● openhab.service - openHAB
Loaded: loaded (/etc/systemd/system/openhab.service; enabled; vendor preset: enabled)
Active: failed (Result: exit-code) since Sat 2020-01-18 10:54:43 AEDT; 8s ago
Process: 7019 ExecStart=/usr/bin/docker run --name=openhab.service --net=home-lan --ip=192.168.1.63 -v /etc/localtime:/etc/localtime:ro -v /etc/timezone:/etc/timezone:ro -v openhab_addons:/open
Main PID: 7019 (code=exited, status=125)
Jan 18 10:54:43 master systemd[1]: openhab.service: Service hold-off time over, scheduling restart.
Jan 18 10:54:43 master systemd[1]: openhab.service: Scheduled restart job, restart counter is at 5.
Jan 18 10:54:43 master systemd[1]: Stopped openHAB.
Jan 18 10:54:43 master systemd[1]: openhab.service: Start request repeated too quickly.
Jan 18 10:54:43 master systemd[1]: openhab.service: Failed with result 'exit-code'.
Jan 18 10:54:43 master systemd[1]: Failed to start openHAB.
Any help would be much appreciated.
Cheers,
Jon