I’ve been neglecting my old OH2.5-installation for a few years since it was simply working. And I was busy with other hobbies. Now the laptop crashed and is gone. Bad timing since my central heating is schedueled through OH.
In the mean time OH3 is out. So I have to learn OH3 and get my old installation working again. I thought I better do this by using docker and install both. But that is new for me too.
I run debian 11 on a laptop, with only terminal. I have ssh-access from windows-laptop.
I have docker installed and using the run-command I can start an OH3-image and access from the windows laptop to http://myserver:8080
Now I like to start two instances: OH2.5.12, and OH3.3, by a services file and point them to ports 8082 and 8083.
The service-file ‘openhab2.service’ does not work for some reason. This is without the port-definition because I’m not sure how the port definition should be in the service-file (with -e in front? or not?)
[Unit]
Description=openHAB
Requires=docker.service
After=docker.service
[Service]
Restart=always
ExecStart=/usr/bin/docker run --name=%n --net=host \
-v /etc/localtime:/etc/localtime:ro \
-v /etc/timezone:/etc/timezone:ro \
-v /opt/openhab/conf:/openhab/conf \
-v /opt/openhab/userdata:/openhab/userdata \
-v /opt/openhab/addons:/openhab/addons \
-v /opt/openhab/.java:/openhab/.java \
--device=/dev/ttyUSB0 \
--devices=/dev/ttyACM0 \
-e USER_ID=998 \
-e GROUP_ID=997 \
-e CRYPTO_POLICY=unlimited \
openhab/openhab:2.5.12-debian ./start_debug.sh
ExecStop=/usr/bin/docker stop -t 2 %n ; /usr/bin/docker rm -f %n
[Install]
WantedBy=multi-user.target
The file openhab3.service is working (that is: there is a docker image started) but I cannot get to the installation web page. This is also without the port-difinition, because when I put the ports in, the file does not work anymore. Must have wrong syntax I think.
[Unit]
Description=openHAB
Requires=docker.service
After=docker.service
[Service]
Restart=always
ExecStart=/usr/bin/docker run --name=openhab3 --net=host \
-v /etc/localtime:/etc/localtime:ro \
-v /etc/timezone:/etc/timezone:ro \
-v /opt/openhab/conf:/openhab/conf \
-v /opt/openhab/userdata:/openhab/userdata \
-v /opt/openhab/addons:/openhab/addons \
-v /opt/openhab/.java:/openhab/.java \
--device=/dev/ttyUSB0 \
--device=/dev/ttyACM0 \
-e USER_ID=998 \
-e GROUP_ID=997 \
-e CRYPTO_POLICY=unlimited \
openhab/openhab:3.3.0
ExecStop=/usr/bin/docker stop -t 2 %n ; /usr/bin/docker rm -f %n
[Install]
WantedBy=multi-user.target
For the ports I tried these lines:
OPENHAB_HTTP_PORT=8080
OPENHAB_HTTPS_PORT=8443
or:
-e OPENHAB_HTTP_PORT=8080 \
-e OPENHAB_HTTPS_PORT=8443 \
I also wonder why the docker image does not get the name openhab3 as indicated in the services file. Instead it only gets a image-tag:
sudo docker images
REPOSITORY TAG IMAGE ID CREATED SIZE
openhab/openhab 3.3.0 46ec3c47adc2 5 months ago 717MB
I hope you can help.