Moving to docker with errors

  • Platform information:
    • Hardware: i3-320
    • OS: Gentoo
    • Java Runtime Environment: don’t remember
    • openHAB version: 2.5.7

Hello everyone,

I have a small bug with my openhab. On my gentoo, I installed openhab to /opt/openhab2 by unzipping it (since it’s not into portage). This work perfectly, but there’s something I can’t find. The folder it try to use is always /opt/openhab2. Because of that, when I move it, it give error that it cannot find this folder.

For instance, I’m trying to move to docker, thus I copied over my files to the new userdata / conf / addons folder and load docker and map these folder per openhab docker doc. This worked, but then again, I’m getting error that it cannot find /opt/openhab2. Where could this path be?

Thank you

You try to use an other folder as root folder for the OH installation instead of /opt/openhab2, right ?
How do you start the OH instance ?
Do you run <…>/runtime/bin/setenv ?

As far as I understand the code ( in setenv ) this should set all the environment variables like OPENHAB_HOME, OPENHAB_USERDATA, … by running oh2_dir_layout.

My old installation was an unzipped in /opt/openhab2. Now, in docker, from the docker doc, everything is in /openhab. Because of that, when I start openhab in docker with my old data, it’s trying to get to /opt/openhab2 for some stuff. It still boot up and stuff work, but I see these errror.

I ran the docker with the same command from the docker page:

docker run
–name openhab
–net=host
-v /etc/localtime:/etc/localtime:ro
-v /etc/timezone:/etc/timezone:ro
-v /opt/openhab/docker/conf:/openhab/conf
-v /opt/openhab/docker/userdata:/openhab/userdata
-v /opt/openhab/docker/addons:/openhab/addons
-d
-e USER_ID=249
-e GROUP_ID=248
-e OPENHAB_HTTP_PORT=9999
-e OPENHAB_HTTPS_PORT=9443
–restart=unless-stopped
openhab/openhab:latest
I doesn’t seem to be the home folder, it’s a lot of felix error. I just did something to find all instance and that’s what I got:

cat * | grep /opt/openhab -R

cat: addons: Is a directory
cat: conf: Is a directory
cat: userdata: Is a directory
userdata/config/org/jupnp.config:felix.fileinstall.filename=“file:/opt/openhab2/userdata/etc/org.jupnp.cfg”
userdata/config/org/ops4j/pax/url/mvn.config:felix.fileinstall.filename=“file:/opt/openhab2/userdata/etc/org.ops4j.pax.url.mvn.cfg”
userdata/config/org/ops4j/pax/url/mvn.config:org.ops4j.pax.url.mvn.defaultRepositories=“file:/opt/openhab2/runtime/system@id=system.repository@snapshots,\ file:/opt/openhab2/userdata/tmp/kar@id=kar.repository@multi@snapshots,\ file:/opt/openhab2/userdata/system@id=child.system.repository@snapshots”
userdata/config/org/ops4j/pax/url/mvn.config:org.ops4j.pax.url.mvn.localRepository=“/opt/openhab2/userdata/tmp/mvn”
userdata/config/org/ops4j/pax/logging.config:felix.fileinstall.filename=“file:/opt/openhab2/userdata/etc/org.ops4j.pax.logging.cfg”
userdata/config/org/ops4j/pax/logging.config:log4j2.appender.audit.fileName=“/opt/openhab2/userdata/logs/audit.log”
userdata/config/org/ops4j/pax/logging.config:log4j2.appender.audit.filePattern=“/opt/openhab2/userdata/logs/audit.log.%i”
userdata/config/org/ops4j/pax/logging.config:log4j2.appender.bindingsdebug.fileName=“/opt/openhab2/userdata/logs/bindingsdebug.log”
userdata/config/org/ops4j/pax/logging.config:log4j2.appender.bindingsdebug.filePattern=“/opt/openhab2/userdata/logs/bindingsdebug.log.%i”
userdata/config/org/ops4j/pax/logging.config:log4j2.appender.cscript.fileName=“/opt/openhab2/userdata/logs/scripts.log”
userdata/config/org/ops4j/pax/logging.config:log4j2.appender.cscript.filePattern=“/opt/openhab2/userdata/logs/scripts.log.%i”
userdata/config/org/ops4j/pax/logging.config:log4j2.appender.dsc.fileName=“/opt/openhab2/userdata/logs/dsc.log”
userdata/config/org/ops4j/pax/logging.config:log4j2.appender.dsc.filePattern=“/opt/openhab2/userdata/logs/dsc.log.%i”
userdata/config/org/ops4j/pax/logging.config:log4j2.appender.dscscript.fileName=“/opt/openhab2/userdata/logs/dscscript.log”
userdata/config/org/ops4j/pax/logging.config:log4j2.appender.dscscript.filePattern=“/opt/openhab2/userdata/logs/dscscript.log.%i”
userdata/config/org/ops4j/pax/logging.config:log4j2.appender.ecobeescript.fileName=“/opt/openhab2/userdata/logs/ecobeescript.log”
userdata/config/org/ops4j/pax/logging.config:log4j2.appender.ecobeescript.filePattern=“/opt/openhab2/userdata/logs/ecobeescript.log.%i”
userdata/config/org/ops4j/pax/logging.config:log4j2.appender.event.fileName=“/opt/openhab2/userdata/logs/events.log”
userdata/config/org/ops4j/pax/logging.config:log4j2.appender.event.filePattern=“/opt/openhab2/userdata/logs/events.log.%i”
userdata/config/org/ops4j/pax/logging.config:log4j2.appender.myq.fileName=“/opt/openhab2/userdata/logs/myq.log”
userdata/config/org/ops4j/pax/logging.config:log4j2.appender.myq.filePattern=“/opt/openhab2/userdata/logs/myq.log.%i”
userdata/config/org/ops4j/pax/logging.config:log4j2.appender.myqc.fileName=“/opt/openhab2/userdata/logs/myq2.log”
userdata/config/org/ops4j/pax/logging.config:log4j2.appender.myqc.filePattern=“/opt/openhab2/userdata/logs/myq2.log.%i”
userdata/config/org/ops4j/pax/logging.config:log4j2.appender.myqscript.fileName=“/opt/openhab2/userdata/logs/myqscript.log”
userdata/config/org/ops4j/pax/logging.config:log4j2.appender.myqscript.filePattern=“/opt/openhab2/userdata/logs/myqscript.log.%i”
userdata/config/org/ops4j/pax/logging.config:log4j2.appender.mysqlpersist.fileName=“/opt/openhab2/userdata/logs/mysqlpersist.log”
userdata/config/org/ops4j/pax/logging.config:log4j2.appender.mysqlpersist.filePattern=“/opt/openhab2/userdata/logs/mysqlpersist.log.%i”
userdata/config/org/ops4j/pax/logging.config:log4j2.appender.out.fileName=“/opt/openhab2/userdata/logs/openhab.log”
userdata/config/org/ops4j/pax/logging.config:log4j2.appender.out.filePattern=“/opt/openhab2/userdata/logs/openhab.log.%i”
userdata/config/org/ops4j/pax/logging.config:log4j2.appender.scenescript.fileName=“/opt/openhab2/userdata/logs/scenescript.log”
userdata/config/org/ops4j/pax/logging.config:log4j2.appender.scenescript.filePattern=“/opt/openhab2/userdata/logs/scenescript.log.%i”
userdata/config/org/ops4j/pax/logging.config:log4j2.appender.sonyaudio.fileName=“/opt/openhab2/userdata/logs/sonyaudio.log”
userdata/config/org/ops4j/pax/logging.config:log4j2.appender.sonyaudio.filePattern=“/opt/openhab2/userdata/logs/sonyaudio.log.%i”
userdata/config/org/ops4j/pax/logging.config:log4j2.appender.weatherunderground.fileName=“/opt/openhab2/userdata/logs/weatherunderground.log”
userdata/config/org/ops4j/pax/logging.config:log4j2.appender.weatherunderground.filePattern=“/opt/openhab2/userdata/logs/weatherunderground.log.%i”
userdata/config/org/ops4j/pax/logging.config:log4j2.appender.wemo.fileName=“/opt/openhab2/userdata/logs/wemo.log”
userdata/config/org/ops4j/pax/logging.config:log4j2.appender.wemo.filePattern=“/opt/openhab2/userdata/logs/wemo.log.%i”
userdata/config/org/ops4j/pax/logging.config:log4j2.appender.wemoscript.fileName=“/opt/openhab2/userdata/logs/wemoscript.log”
userdata/config/org/ops4j/pax/logging.config:log4j2.appender.wemoscript.filePattern=“/opt/openhab2/userdata/logs/wemoscript.log.%i”
userdata/config/org/ops4j/pax/web.config:felix.fileinstall.filename=“file:/opt/openhab2/userdata/etc/org.ops4j.pax.web.cfg”
userdata/config/org/ops4j/pax/web.config:org.ops4j.pax.web.config.file=“/opt/openhab2/runtime/etc/jetty.xml”
userdata/config/org/eclipse/smarthome/voice.config:felix.fileinstall.filename=“file:/opt/openhab2/userdata/etc/org.eclipse.smarthome.voice.cfg”
userdata/config/org/eclipse/smarthome/audio.config:felix.fileinstall.filename=“file:/opt/openhab2/userdata/etc/org.eclipse.smarthome.audio.cfg”
userdata/config/org/apache/felix/eventadmin/impl/EventAdmin.config:felix.fileinstall.filename=“file:/opt/openhab2/userdata/etc/org.apache.felix.eventadmin.impl.EventAdmin.cfg”
userdata/config/org/apache/felix/fileinstall/fbd39dee-fa7d-4285-b05b-8c8632216b2f.config:felix.fileinstall.dir=“/opt/openhab2/addons”
userdata/config/org/apache/felix/fileinstall/fbd39dee-fa7d-4285-b05b-8c8632216b2f.config:felix.fileinstall.filename=“file:/opt/openhab2/userdata/etc/org.apache.felix.fileinstall-deploy.cfg”
userdata/config/org/apache/felix/fileinstall/fbd39dee-fa7d-4285-b05b-8c8632216b2f.config:felix.fileinstall.tmpdir=“/opt/openhab2/userdata/tmp/bundles”
userdata/config/org/apache/felix/fileinstall/c9be75da-2265-4730-893d-360298a0a70d.config:felix.fileinstall.dir=“/opt/openhab/current/addons”
userdata/config/org/apache/felix/fileinstall/c9be75da-2265-4730-893d-360298a0a70d.config:felix.fileinstall.filename=“file:/opt/openhab/2.5.4/userdata/etc/org.apache.felix.fileinstall-deploy.cfg”
userdata/config/org/apache/felix/fileinstall/c9be75da-2265-4730-893d-360298a0a70d.config:felix.fileinstall.tmpdir=“/opt/openhab/2.5.4/userdata/tmp/bundles”
userdata/config/org/apache/felix/fileinstall/afe1607d-f71c-40d7-9f3d-a9ea728bbdf6.config:felix.fileinstall.dir=“/opt/openhab2/addons”
userdata/config/org/apache/felix/fileinstall/afe1607d-f71c-40d7-9f3d-a9ea728bbdf6.config:felix.fileinstall.filename=“file:/opt/openhab2/userdata/etc/org.apache.felix.fileinstall-deploy.cfg”
userdata/config/org/apache/felix/fileinstall/afe1607d-f71c-40d7-9f3d-a9ea728bbdf6.config:felix.fileinstall.tmpdir=“/opt/openhab2/userdata/tmp/bundles”
userdata/config/org/apache/karaf/features.config:felix.fileinstall.filename=“file:/opt/openhab/2.5.4/userdata/etc/org.apache.karaf.features.cfg”
userdata/config/org/apache/karaf/jaas.config:felix.fileinstall.filename=“file:/opt/openhab2/userdata/etc/org.apache.karaf.jaas.cfg”
userdata/config/org/apache/karaf/shell.config:felix.fileinstall.filename=“file:/opt/openhab2/userdata/etc/org.apache.karaf.shell.cfg”
userdata/config/org/apache/karaf/shell.config:hostKey=“/opt/openhab2/userdata/etc/host.key”
userdata/config/org/apache/karaf/kar.config:felix.fileinstall.filename=“file:/opt/openhab2/userdata/etc/org.apache.karaf.kar.cfg”
userdata/config/org/apache/karaf/kar.config:karStorage=“/opt/openhab2/userdata/tmp/kar”
userdata/config/org/apache/karaf/log.config:felix.fileinstall.filename=“file:/opt/openhab2/userdata/etc/org.apache.karaf.log.cfg”
userdata/config/org/apache/karaf/features/repos.config:felix.fileinstall.filename=“file:/opt/openhab/2.5.4/userdata/etc/org.apache.karaf.features.repos.cfg”
userdata/config/org/apache/karaf/command/acl/system.config:felix.fileinstall.filename=“file:/opt/openhab2/userdata/etc/org.apache.karaf.command.acl.system.cfg”
userdata/config/org/apache/karaf/command/acl/feature.config:felix.fileinstall.filename=“file:/opt/openhab/2.5.4/userdata/etc/org.apache.karaf.command.acl.feature.cfg”
userdata/config/org/apache/karaf/command/acl/jaas.config:felix.fileinstall.filename=“file:/opt/openhab2/userdata/etc/org.apache.karaf.command.acl.jaas.cfg”
userdata/config/org/apache/karaf/command/acl/shell.config:felix.fileinstall.filename=“file:/opt/openhab2/userdata/etc/org.apache.karaf.command.acl.shell.cfg”
userdata/config/org/apache/karaf/command/acl/scope_bundle.config:felix.fileinstall.filename=“file:/opt/openhab2/userdata/etc/org.apache.karaf.command.acl.scope_bundle.cfg”
userdata/config/org/apache/karaf/command/acl/kar.config:felix.fileinstall.filename=“file:/opt/openhab2/userdata/etc/org.apache.karaf.command.acl.kar.cfg”
userdata/config/org/apache/karaf/command/acl/config.config:felix.fileinstall.filename=“file:/opt/openhab2/userdata/etc/org.apache.karaf.command.acl.config.cfg”
userdata/config/org/apache/karaf/command/acl/bundle.config:felix.fileinstall.filename=“file:/opt/openhab2/userdata/etc/org.apache.karaf.command.acl.bundle.cfg”
userdata/config/jmx/acl/org/apache/karaf/config.config:felix.fileinstall.filename=“file:/opt/openhab2/userdata/etc/jmx.acl.org.apache.karaf.config.cfg”
userdata/config/jmx/acl/org/apache/karaf/bundle.config:felix.fileinstall.filename=“file:/opt/openhab2/userdata/etc/jmx.acl.org.apache.karaf.bundle.cfg”
userdata/config/profile.config:felix.fileinstall.filename=“file:/opt/openhab/2.5.4/userdata/etc/profile.cfg”
userdata/config/com/eclipsesource/jaxrs/connector.config:felix.fileinstall.filename=“file:/opt/openhab2/userdata/etc/com.eclipsesource.jaxrs.connector.cfg”
userdata/config/com/eclipsesource/jaxrs/swagger/config.config:felix.fileinstall.filename=“file:/opt/openhab2/userdata/etc/com.eclipsesource.jaxrs.swagger.config.cfg”
userdata/tmp/instances/instance.properties:item.0.loc = /opt/openhab2/userdata

Does the startup in docker set the environment variables ( OPENHAB_HOME, etc. ) ?
I did not check all the files that you posted but those that I checked are not part of the zip file thus these files mustbe generated during initial startup of OH.

Yes, it set it to /openhab. But what I found out is that it’s hardcoded in the files (that’s what my command showed). What I did is run a sed to replace the string in all of the files and now no more error. Just weird that these file have hardcoded path.

It’s hardcoded in those files because of the execution of oh2_dir_layout.
The output are the files you listed containing the path detected during runtime of oh2_dir_layout.

ok, but why not use the same var there too?

That is only within the Docker container. Your shared volumes can point to wherever you desire. I am currently testing with /opt/openhab but may try /srv/openhab to better align with the FHS 3.0 filesystem standard. The volume location is determined in either your docker run command or your docker-compose configuration file.

That wasn’t the problem. Problem was that some file had hardcoded path in them. Since it come from an installation that was on /opt/openhab, it was looking there. All my mounts are correct on docker.

Also, I’m unsure about fhs 3.0, for me the new place was /opt, I saw everything everywhere get there in the past 2 years on all doc I saw. I’m unused to that since I used to work with Linux in the 90s.

It is hard-coded within the container but there is usually no reason to look there. The documentation on Docker Hub is quite clear in their examples.

No worries. It is a Linux standard. I like having everything in one place too but files that are changing do not belong in /opt. That is just a technicality.

https://refspecs.linuxfoundation.org/FHS_3.0/fhs/ch03s13.html

It is not hardcoded in the container. It is hardcoded in files under user data. If you look at what I quoted, it’s part of files I copied over from my zip installation. I even had 3 different hardcoded path in the end because I had moved it 3 times in the past trying to make a standard until I saw all the error saying it always search for /opt/openhab2. Since now I moved to docker, it gave me the same error I had in the past and I wanted to get rid of this error.

Exact, this is the reason why you see these paths.
If you would start openHAB in docker from ‘scratch’ without these files you should get correct paths in the files under userdata as they are created during ( first ) runtime.
This is intended by design of OH and makes the paths in the files independent of OSs.

Yeah I just don’t get why these are hardcoded. It should used the homedir var like the rest. It means the installation can’t be moved because of that. At least I still have some basic skill left in my brain and was able to sed all the path to the new one and it fixed the issue. This problem is outside of docker, can be reproduce with any installation.

It is using the homedir Here is the line from the script. for 2.5.7

adduser -u $NEW_USER_ID --disabled-password --gecos '' --home "${OPENHAB_HOME}" --gid $NEW_GROUP_ID openhab

If you wish to file an Issue or PR, here is the file
https://github.com/openhab/openhab-docker/blob/master/2.5.7/debian/entrypoint.sh

We are not talking about the same thing.

Forget Docker, it has nothing to do with docker in the end. The problem is, in a running instance, some file are created while running and in those file, it used an hardcoded path. If you check my log up there, I did a command to read all files and chech for the path “/opt/openhab”. It returned many files that are saved under “userdata/config/”, “userdata/tmp/instances/” and “userdata/etc”.

you can see in these file, for exemple, in the file “userdata/config/org/jupnp.config”, there is a line that says “felix.fileinstall.filename=“file:/opt/openhab2/userdata/etc/org.jupnp.cfg””

The path is hardcoded, no var. It might have been created at first with a homedir var, but now it doesn’t use it anyway. And that’s where I’m saying it’s bad, it should keep the var when there’s a var and be expended at runtime like all other var.

Nothing to do with Debian, Docker, entrypoint or anything like that. It’s just how the runtime is. Outside of docker, if I move my old installation to a new folder like I did when I switched from 2.4 to 2.5.1, it caused the same problem, out of docker.

1 Like

It’s a known issue:

Those files are managed by Apache Felix File Install which is a dependency of Karaf, which is a dependency of openHAB. So it is unaware of all these OH specific configuration variables.

AH, that explain why. Would need something on boot-up that check if it was moved from last known location to trigger a rebuild on these file.