Restore openhab instance in docker container

I am running openhab in LXC right now and want to switch to docker.

  1. I did a backup and copied the file to a host directory

  2. I unzipped the backup file. I got userdata, backup-properties and con as folders with content

  3. I started the docker container. Directory “addons” was added.
    docker run --name openhab --network=nextcloudpi -p 8091:8080 -v /etc/localtime:/etc/localtime:ro -v /etc/timezone:/etc/timezone:ro -v /docker/volumes/openhab/addons:/openhab/addons -v /docker/volumes/openhab/conf:/openhab/conf -v /docker/volumes/openhab/userdata:/openhab/userdata -e "CRYPTO_POLICY=unlimited" -e "EXTRA_JAVA_OPTS=-Duser.timezone=Europe/Berlin" -d --restart=always openhab/openhab:latest

  4. Got the error:

Launching the openHAB runtime...
Error occurred shutting down framework: java.lang.NumberFormatException: null
java.lang.NumberFormatException: null
        at java.base/java.lang.Integer.parseInt(
        at java.base/java.lang.Integer.parseInt(
        at org.apache.karaf.main.ConfigProperties.<init>(
        at org.apache.karaf.main.Main.updateInstancePidAfterShutdown(
        at org.apache.karaf.main.Main.main(
  1. Tried the restore with the console, but I get the error:

openHAB is running! Please stop the process before restoring.

I do not know how to stop the openhab service in the docker container. If I stop the whole container, I cannot run the restore.
I tried to stop the openhab service with /openhab/bin/stop, but this stops the whole container.
I also tried systemctl service stop openhab3.service

First, make sure the old version and new version are exactly the same. The restore will not perform upgrade steps.

Then you have two options.

  1. Create a script that runs the restore and mount it to /etc/cont-init.d in the container (see the “Executing shell scripts before openHAB is started” section of the Docker image docs): Docker

  2. Simply unzip the backup file on the host putting the “conf” contents in the host’s folder mounted to conf and the “userdata” contents in the host’s folder mounted to userdata. But you have to make sure that the folder structure is the same (e.g. you don’t have conf/conf/items).