OpenHAB3 Docker Test Instance on Synology

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:

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:
- “/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”

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/ 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'

  openhab: #Production OH2 Container
    container_name: openhab
    image: "openhab/openhab:latest"
    restart: always
    network_mode: host
      - "/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"
      USER_ID: "1072"
      OPENHAB_HTTP_PORT: "8080"
      OPENHAB_HTTPS_PORT: "8443"
      EXTRA_JAVA_OPTS: "-Duser.timezone=US/Eastern -"
      LC_ALL: "en_US.UTF-8"
      LANG: "en_US.UTF-8"
      LANGUAGE: "en_US.UTF-8"
      - "/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
      - "/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"
      USER_ID: "1072"
      OPENHAB_HTTP_PORT: "8085"
      OPENHAB_HTTPS_PORT: "8448"
      EXTRA_JAVA_OPTS: "-Duser.timezone=US/Eastern -"
      LC_ALL: "en_US.UTF-8"
      LANG: "en_US.UTF-8"
      LANGUAGE: "en_US.UTF-8"
      - "/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.

Old Ag

Platform information: Synology DS918+
Hardware: Intel Celleron J3455/16GB Ram
OS: 6.2.3
Java Runtime Environment: Container Dependent (Zulu for OH2.5/Zulu 11.0.8 OH3.0.0)
openHAB version: 2.5.9/3.0.0


@Old_Ag Thanks for posting this, I was inspired to set up a similar container and try this out.

I’ve got it all running, but can’t install bindings or UIs. I suspect it’s about user privileges but not sure.

I don’t see anything in the container logs and the OH3 logs just show installation failed. Did you need to do anything with privileges?

I experienced the same thing initially. It resolved itself, but I was playing with so many changes, I’m not 100% sure how it was resolved. I think the fix is this:

Turn off Access Remote Repository in Add-on Management under Settings

Restart the container.

Turn Access Remote Repository back on.

It’s just a wild guess. But mine started working somewhere along the way.

I didn’t change any permissions and used the same user ID already set up on the NAS for OH 2.

Old Ag

1 Like

Thanks @Old_Ag

It was as simple as that…

I don’t use compose but the UI from Synology and Portainer. No way in hell did I find how to change the ports… I changed homebridge and Unifi away from the 8080 port (damn the popularity of that port :slight_smile: ) Any idea where I can change the ENV variable and persist it? Or is compose the only way?

When you create the container with the UI you can select advanced in the options. There you can set network, mapping and environment variables.

Only when bridging, not on host. And on bridging I can’t install bindings and there seems to be user isdues also. Useradd dies not work, and the syntax of synouser is different…

@Old_Ag thank you for this very usefull documention.
I’d like to test OH3 on docker while the OH2.5 is running as a package, not within docker.
As you imagine, I’m new in the docker world :slight_smile:
When running docker-compose command, some errors are raised :

Can’t find a suitable configuration file in this directory or any
parent. Are you in the right directory?

So, my question is quite simple: in which folder do I have to be?
Docker is installed on volume1, standard installed
and I’ve download the OpenHAB3-RC2 image.
Tahnks for your help

First cd to the directory that contains your docker-compose.yml file and then execute a docker-compose command. That way Docker Compose will be able to find the configuration file.

Hello thank you
I am a beginner
i’m stuck on mounting volumes
see attachment please
When I use:
Create container openhab-openhab1 failed: {“message”:“invalid volume specification: ‘/volume2/docker/Openhab/etc-timezone:/etc/timezone:ro:rw’”}.

When I use=

Start container openhab-openhab1 failed: {“message”:“OCI runtime create failed: container_linux.go:345: starting container process caused “process_linux.go:430: container init caused \“rootfs_linux.go:59: mounting \\\”/volume2/docker/OpenHab/etc-timezone\\\” to rootfs \\\”/volume2/@docker/btrfs/subvolumes/27a62b872ce9630e87b8ab7391a06a81f0cdf96371f6f04174d2ce5e92d4c58e\\\" at \\\"/volume2/@docker/btrfs/subvolumes/27a62b872ce9630e87b8ab7391a06a81f0cdf96371f6f04174d2ce5e92d4c58e/etc/timezone\\\" caused \\\“not a directory\\\”\"": unknown: Are you trying to mount a directory onto a file (or vice-versa)? Check if the specified host path exists and is the expected type"}.

can you give me a solution please ?

Thank you for this. I couldn’t find any documentation on how to change the console port and it was driving me nuts.

Do you find that, when you have both containers running at the same time, your .items and .things files do not get reloaded until you restart the container? I’ve got this up and mostly working, but if I add an item, I have to restart the entire container for OH to pick it up. This problem seems to go away when I run only the OH3 container (haven’t tried it the other way around).

Haven’t noticed that, but I don’t keep them both running at the same time. However, I would only expect that sort of thing if you were using the same directories for both instances. Using separate directories (./OpenHAB and ./OpenHAB3) should prevent conflicts, which is what it sounds like you have going on.