These are just a few observations on running OH2.5.X in production next to OH 3.0.0 for testing, installed in Docker containers on a Synology NAS.
First: The reference for OpenHAB on Docker is here: https://github.com/openhab/openhab-docker#running-on-windows-and-macos
In my case I’m running Docker on a Synology NAS, so some of the Synology Linux distro is a little different from standard Linux.
You’ll need ssh access to the NAS. Also remember to log in with root access: sudo su -
If you want to run two containers side by side, you’ll have to change the default ports.
For the UI, change the default ports (the below are incremented by 5 from the default, but you can pick your own port). I use Docker Compose (Version 2), so my changes are:
To persist your configuration, you’ll have to set up a new OpenHAB3 volume structure for the OH3 test instance. You’ll need a different name from your OH2.5.X volume for the root OH3 volume. In my case, I chose OpenHAB3. You’ll need all the subdirectories in place as well: addon, conf, userdata. Under conf you’ll need the necessary subdirectories. Once you get OH3 started, watch the console for errors related to missing directories and add them later.
While these all may not be necessary in all configurations, I mapped them in my Docker Compose file as well:
At this point, you can create the container. With compose, the command is:
docker-compose up -d openhab3
This creates the container based on the Docker Compose yaml file using the openhab3 configuration below. I’ve included my complete file below for reference.
Once the container starts, you’ll have to change the ssh port for the Karaf console, otherwise you will only be able to log into the OH 2.5.x console if its running.
This is done by editing /OpenHab3/userdata/etc/org.apache.karaf.shell.cfg to change Karaf ssh port from the default 8101 to another number (In my case I again increment by five):
sshPort = 8106
Now restart the container.
If all is done correctly, you can access the OH3 console with:
docker exec -it openhab3 /openhab/runtime/bin/client
For reference, my Docker Compose file (named docker-compose.yaml):
Notes: Indent level is critical and should not be done with tabs, only spaces. I’ve included openhab which is my production version and openhab3 which is the OH3 test container:
version: '2' services: openhab: #Production OH2 Container container_name: openhab image: "openhab/openhab:latest" restart: always network_mode: host volumes: - "/etc/localtime:/etc/localtime:ro" - "/etc/TZ:/etc/timezone:ro" - "./openHAB/addons:/openhab/addons" - "./openHAB/conf:/openhab/conf" - "./openHAB/userdata:/openhab/userdata" - "./openHAB/photos:/openhab/photos" - "./openHAB/conf/html:/openhab/conf/html" environment: USER_ID: "1072" OPENHAB_HTTP_PORT: "8080" OPENHAB_HTTPS_PORT: "8443" EXTRA_JAVA_OPTS: "-Duser.timezone=US/Eastern - Dgnu.io.rxtx.SerialPorts=/dev/ttyUSB0:/dev/ttyUSB1" LC_ALL: "en_US.UTF-8" LANG: "en_US.UTF-8" LANGUAGE: "en_US.UTF-8" devices: - "/dev/ttyUSB0:/dev/ttyUSB1" - "/dev/ttyUSB1:/dev/ttyUSB2" openhab3: #OpenHAB 3.0 Test Container container_name: openhab3 image: "openhab/openhab:3.0.0-snapshot" restart: always network_mode: host volumes: - "/etc/localtime:/etc/localtime:ro" - "/etc/TZ:/etc/timezone:ro" - "./openHAB3/addons:/openhab/addons" - "./openHAB3/conf:/openhab/conf" - "./openHAB3/userdata:/openhab/userdata" - "./openHAB3/photos:/openhab/photos" - "./openHAB3/conf/html:/openhab/conf/html" environment: USER_ID: "1072" OPENHAB_HTTP_PORT: "8085" OPENHAB_HTTPS_PORT: "8448" EXTRA_JAVA_OPTS: "-Duser.timezone=US/Eastern - Dgnu.io.rxtx.SerialPorts=/dev/ttyUSB0:/dev/ttyUSB1" LC_ALL: "en_US.UTF-8" LANG: "en_US.UTF-8" LANGUAGE: "en_US.UTF-8" devices: - "/dev/ttyUSB0:/dev/ttyUSB1" - "/dev/ttyUSB1:/dev/ttyUSB2"
Other things to note:
I have a ZWave/ZigBee stick as evidenced by the devices entry in the compose file. It will work with one of the containers at a time, but not both.
The Language Server Protocol (LSP) may throw an error if both containers are running at the same time due to a port conflict. Running one at a time solves it. I haven’t yet bothered with finding the configuration for the LSP port.
The Java 11 dependency is handled within the container, so no need to figure out how to install Java 11 on your Synology NAS.
I’m no expert here, but I did manage to get side by side OH2.5.X and OH3 containers running.
Platform information: Synology DS918+
Hardware: Intel Celleron J3455/16GB Ram
Java Runtime Environment: Container Dependent (Zulu 184.108.40.206 for OH2.5/Zulu 11.0.8 OH3.0.0)
openHAB version: 2.5.9/3.0.0