Docker on RancherOS - how to handle the openhab user?

Hi there,

I noticed that RancherOS does not support other users than rancher:
https://rancher.com/docs/os/v1.2/en/configuration/users/

When starting openhab in docker I specified the rancher USER_ID and GROUP_ID like here:

Which seems to work but I saw lines like this in my logs:
Cannot access RandomAccessFile java.io.IOException: Could not create directory /var/log/openhab2

Can anyone tell me how to correctly handle this?

What’s the permission on the log directory? It must allow read/write for the rancher user or group.

Thank you for the reply @rlkoshak

I’m not sure, I’m not mounting /var/log/ to an external volume. This is what I’m using:

 docker run \
        --name openhab \
        -v /etc/localtime:/etc/localtime:ro \
        -v /etc/timezone:/etc/timezone:ro \
        -v /home/rancher/docker/openhab/conf:/openhab/conf \
        -v /home/rancher/docker/openhab/userdata:/openhab/userdata \
        -v /home/rancher/docker/openhab/addons:/openhab/addons\
        -v /home/rancher/docker/openhab/backups:/openhab/backups\
        -d \
        -e USER_ID=1100 \
        -e GROUP_ID=1100 \
        -p 8080:8080 \
        --link homegear:homegear \
        --restart=always \
        openhab/openhab:2.4.0-armhf-alpine

Or did I miss something?

The Docker image uses a manual install of OH instead of an apt install of OH. Consequently the logs get saved to /openhab/userdata/logs. Check the permissions on that folder (and all your userdata folders for that matter) and make sure the rancher user or group has write permissions.

@rlkoshak thank you, I see.

The permissions seem to be alright though:

 rancher:x:1100:1100:Linux User,,,:/home/rancher:/bin/bash

drwxr-xr-x    2 rancher  rancher       4096 Feb 27 06:52 log

is there anything else I can do?

I don’t use RancherOS so have nothing else to recommend.

I think it’s an openhab issue, not Rancher - as the permissions are specified and should be alright.

Wait, did you restore your userdata/etc folder from an installed openHAB instance? I’m just noticing that it is trying to log to /var/log/openhab2 which is not the correct location for a Docker instance. It should be logging to /openhab/userdata/log.

There is a variable called ${openhab.logdir} used in userdata/etc/org.ops4j.pax.logging.cfg. Have you changed this variable or are you using this variable in that file?

Are you using the official Docker image?

This variable is passed to OH in runtime/bin/setenv and it should be defaulting to /openhab/userdata/log not /var/log/openhab2.

Maybe you can set an environment variable using -e on the docker command to override the value it is currently using.

Thanks @rlkoshak I think that’s the problem. I see there are many references in userdata/config:

 com/eclipsesource/jaxrs/swagger/config.config:felix.fileinstall.filename="file:/var/lib/openhab2/etc/com.eclipsesource.jaxrs.swagger.config.cfg"
com/eclipsesource/jaxrs/connector.config:felix.fileinstall.filename="file:/var/lib/openhab2/etc/com.eclipsesource.jaxrs.connector.cfg"
jmx/acl/java/lang/Memory.config:felix.fileinstall.filename="file:/var/lib/openhab2/etc/jmx.acl.java.lang.Memory.cfg"
jmx/acl/org/apache/karaf/config.config:felix.fileinstall.filename="file:/var/lib/openhab2/etc/jmx.acl.org.apache.karaf.config.cfg"
jmx/acl/org/apache/karaf/security/jmx.config:felix.fileinstall.filename="file:/var/lib/openhab2/etc/jmx.acl.org.apache.karaf.security.jmx.cfg"
jmx/acl/org/apache/karaf/bundle.config:felix.fileinstall.filename="file:/var/lib/openhab2/etc/jmx.acl.org.apache.karaf.bundle.cfg"
jmx/acl/osgi/compendium/cm.config:felix.fileinstall.filename="file:/var/lib/openhab2/etc/jmx.acl.osgi.compendium.cm.cfg"
jmx/acl.config:felix.fileinstall.filename="file:/var/lib/openhab2/etc/jmx.acl.cfg"
org/openhab/addons.config:felix.fileinstall.filename="file:/var/lib/openhab2/etc/org.openhab.addons.cfg"
org/jupnp.config:felix.fileinstall.filename="file:/var/lib/openhab2/etc/org.jupnp.cfg"
org/apache/karaf/command/acl/shell.config:felix.fileinstall.filename="file:/var/lib/openhab2/etc/org.apache.karaf.command.acl.shell.cfg"
org/apache/karaf/command/acl/feature.config:felix.fileinstall.filename="file:/var/lib/openhab2/etc/org.apache.karaf.command.acl.feature.cfg"
org/apache/karaf/command/acl/jaas.config:felix.fileinstall.filename="file:/var/lib/openhab2/etc/org.apache.karaf.command.acl.jaas.cfg"
org/apache/karaf/command/acl/config.config:felix.fileinstall.filename="file:/var/lib/openhab2/etc/org.apache.karaf.command.acl.config.cfg"
org/apache/karaf/command/acl/kar.config:felix.fileinstall.filename="file:/var/lib/openhab2/etc/org.apache.karaf.command.acl.kar.cfg"
org/apache/karaf/command/acl/scope_bundle.config:felix.fileinstall.filename="file:/var/lib/openhab2/etc/org.apache.karaf.command.acl.scope_bundle.cfg"
org/apache/karaf/command/acl/system.config:felix.fileinstall.filename="file:/var/lib/openhab2/etc/org.apache.karaf.command.acl.system.cfg"
org/apache/karaf/command/acl/bundle.config:felix.fileinstall.filename="file:/var/lib/openhab2/etc/org.apache.karaf.command.acl.bundle.cfg"
org/apache/karaf/jaas.config:felix.fileinstall.filename="file:/var/lib/openhab2/etc/org.apache.karaf.jaas.cfg"
org/apache/karaf/management.config:felix.fileinstall.filename="file:/var/lib/openhab2/etc/org.apache.karaf.management.cfg"
org/apache/karaf/log.config:felix.fileinstall.filename="file:/var/lib/openhab2/etc/org.apache.karaf.log.cfg"
org/apache/felix/eventadmin/impl/EventAdmin.config:felix.fileinstall.filename="file:/var/lib/openhab2/etc/org.apache.felix.eventadmin.impl.EventAdmin.cfg"
org/apache/felix/fileinstall/7d38c56a-5feb-4f18-9135-11d4643c6db9.config:felix.fileinstall.filename="file:/var/lib/openhab2/etc/org.apache.felix.fileinstall-deploy.cfg"
org/eclipse/smarthome/basicui.config:felix.fileinstall.filename="file:/var/lib/openhab2/etc/org.eclipse.smarthome.basicui.cfg"
org/eclipse/smarthome/audio.config:felix.fileinstall.filename="file:/var/lib/openhab2/etc/org.eclipse.smarthome.audio.cfg"
org/eclipse/smarthome/voice.config:felix.fileinstall.filename="file:/var/lib/openhab2/etc/org.eclipse.smarthome.voice.cfg"
org/eclipse/smarthome/links.config:felix.fileinstall.filename="file:/var/lib/openhab2/etc/org.eclipse.smarthome.links.cfg"

is there any way to migrate this? Or, since I didn’t change these files, could I just remove them and they will be recreated?

What I would do is mount some other folder into user data when the container starts. The entry point script will see the empty code and populate it with the Diageo defaults. You can then copy over the jsondb and reinstall the bindings, if you have done any setup at all.

I thought I could just copy userdata/config/ from a new install, but I guess it isn’t that easy as it then shows me the new setup wizard…