Docker image fails to startup when mapping userdata folder

  • Platform information:
    • Hardware: pentium j5005/16G
    • OS: openmediavault 5 on debian
    • openHAB version: 2
  • Issue of the topic:
    I am trying to move my openhab2 setup from windows to a docker in my omv5 machine.

I have setup a docker-compose.yml per the instructions at: https://hub.docker.com/r/openhab/openhab and https://www.openhab.org/docs/installation/docker.html

I first started up my openhab container without mapping any volumes to userdata or conf just to make sure I had my ports setup correctly. Openhab2 started up just fine and I was able to on the web gui.

I then mapped my userdata and conf volumes to blank new folders. And now when I run docker-compose up I get:

docker-compose up
 ...     
openhab    | ++ IFS=' '
openhab    | ++ echo gosu openhab tini -s ./start.sh
openhab    | + '[' 'gosu openhab tini -s ./start.sh' == 'gosu openhab tini -s ./start.sh' ']'
openhab    | + command=($@ server)
openhab    | + exec gosu openhab tini -s ./start.sh server
openhab    | Launching the openHAB runtime...
openhab    | mmap failed for CEN and END part of zip file
openhab    | Error installing bundle listed in startup.properties with url:   mvn:org.apache.karaf.features/org.apache.karaf.features.extension/4.2.7 and startlevel: 1
openhab exited with code 255

My docker-compose file looks like this:
version: ‘2.2’

services:
  openhab:
    image: "openhab/openhab"
    container_name: openhab
    restart: unless-stopped
    network_mode: host
    volumes:
      - "/etc/localtime:/etc/localtime:ro"
      - "/etc/timezone:/etc/timezone:ro"
      - "/opt/openhab/addons:/openhab/addons"
      - "/opt/openhab/conf:/openhab/conf"
      - "/opt/openhab/userdata:/openhab/userdata"
    environment:
      USER_ID: "1005"
      GROUP_ID: "1000"
      OPENHAB_HTTP_PORT: "8080"
      OPENHAB_HTTPS_PORT: "8443"
      EXTRA_JAVA_OPTS: "-Duser.timezone=America/Los_Angeles"
      CRYPTO_POLICY: "limited"
    devices:
      - "/dev/ttyUSB0:/dev/ttyUSB0"
      - "/dev/ttyUSB1:/dev/ttyUSB1"
    ports:
      - 8080:8080
      - 8443:8443

Please help.

When the container starts it looks in the userdata folder and if it doesn’t see the right file (I think it looks for etc/versions.properties if I recall correctly). If that file doesn’t exist it is supposed to copy over a default set of all the config files needed to run OH. Did the container add anything to your mapped in userdata folder?

1 Like

This is what was created :
/opt/openhab/userdata/cache:
total 12
drwxr-sr-x 3 openhab openhab 4096 Oct 5 21:58 .
drwxr-sr-x 6 openhab openhab 4096 Oct 5 21:58 …
drwxr-sr-x 3 openhab openhab 4096 Oct 5 21:58 org.eclipse.osgi

/opt/openhab/userdata/etc:
total 244
drwxr-sr-x 3 openhab openhab  4096 Sep 20 09:33 .
drwxr-sr-x 6 openhab openhab  4096 Oct  5 21:58 ..
-rw-r--r-- 1 openhab openhab  1035 Sep 20 09:31 all.policy
-rw-r--r-- 1 openhab openhab  1060 Sep 20 09:33 branding.properties
-rw-r--r-- 1 openhab openhab  1060 Sep 20 09:33 branding-ssh.properties
-rw-r--r-- 1 openhab openhab    10 Sep 20 09:33 com.eclipsesource.jaxrs.connector.cfg
-rw-r--r-- 1 openhab openhab    59 Sep 20 09:33 com.eclipsesource.jaxrs.swagger.config.cfg
-rw-r--r-- 1 openhab openhab 12965 Oct  5 21:58 config.properties
-rw-r--r-- 1 openhab openhab   317 Sep 20 09:33 custom.properties
-rw-r--r-- 1 openhab openhab   459 Sep 20 09:33 custom.system.properties
-rw-r--r-- 1 openhab openhab  1144 Sep 20 09:31 distribution.info
-rw-r--r-- 1 openhab openhab  4616 Sep 20 09:31 equinox-debug.properties
-rw-r--r-- 1 openhab openhab   252 Sep 20 09:33 java.util.logging.properties
-rw-r--r-- 1 openhab openhab  1664 Sep 20 09:32 jmx.acl.org.apache.karaf.bundle.cfg
-rw-r--r-- 1 openhab openhab  3316 Sep 20 09:32 jmx.acl.org.apache.karaf.config.cfg
-rw-r--r-- 1 openhab openhab 19047 Sep 20 09:31 jre.properties
-rw-r--r-- 1 openhab openhab  2095 Sep 20 09:31 keys.properties
-rw-r--r-- 1 openhab openhab    32 Sep 20 09:33 keystore
-rw-r--r-- 1 openhab openhab   493 Sep 20 09:33 org.apache.felix.eventadmin.impl.EventAdmin.cfg
-rw-r--r-- 1 openhab openhab   371 Sep 20 09:33 org.apache.felix.fileinstall-deploy.cfg
-rw-r--r-- 1 openhab openhab  1737 Sep 20 09:32 org.apache.karaf.command.acl.bundle.cfg
-rw-r--r-- 1 openhab openhab  2025 Sep 20 09:32 org.apache.karaf.command.acl.config.cfg
-rw-r--r-- 1 openhab openhab  1141 Sep 20 09:32 org.apache.karaf.command.acl.feature.cfg
-rw-r--r-- 1 openhab openhab  1154 Sep 20 09:32 org.apache.karaf.command.acl.jaas.cfg
-rw-r--r-- 1 openhab openhab  1219 Sep 20 09:32 org.apache.karaf.command.acl.kar.cfg
-rw-r--r-- 1 openhab openhab  1376 Sep 20 09:32 org.apache.karaf.command.acl.scope_bundle.cfg
-rw-r--r-- 1 openhab openhab  1118 Sep 20 09:32 org.apache.karaf.command.acl.shell.cfg
-rw-r--r-- 1 openhab openhab  1384 Sep 20 09:32 org.apache.karaf.command.acl.system.cfg
-rw-r--r-- 1 openhab openhab  3199 Sep 20 09:33 org.apache.karaf.features.cfg
-rw-r--r-- 1 openhab openhab  3724 Sep 20 09:32 org.apache.karaf.features.repos.cfg
-rw-r--r-- 1 openhab openhab  1694 Sep 20 09:31 org.apache.karaf.features.xml
-rw-r--r-- 1 openhab openhab   834 Sep 20 09:33 org.apache.karaf.jaas.cfg
-rw-r--r-- 1 openhab openhab   532 Sep 20 09:33 org.apache.karaf.kar.cfg
-rw-r--r-- 1 openhab openhab   758 Sep 20 09:33 org.apache.karaf.log.cfg
-rw-r--r-- 1 openhab openhab  4161 Sep 20 09:33 org.apache.karaf.shell.cfg
-rw-r--r-- 1 openhab openhab    33 Sep 20 09:32 org.eclipse.smarthome.audio.cfg
-rw-r--r-- 1 openhab openhab    22 Sep 20 09:32 org.eclipse.smarthome.voice.cfg
-rw-r--r-- 1 openhab openhab    65 Sep 20 09:33 org.jupnp.cfg
-rw-r--r-- 1 openhab openhab  6350 Sep 20 09:33 org.ops4j.pax.logging.cfg
-rw-r--r-- 1 openhab openhab  5751 Sep 20 09:33 org.ops4j.pax.url.mvn.cfg
-rw-r--r-- 1 openhab openhab  1346 Sep 20 09:33 org.ops4j.pax.web.cfg
-rw-r--r-- 1 openhab openhab     0 Sep 20 09:33 overrides.properties
-rw-r--r-- 1 openhab openhab  7933 Sep 20 09:32 profile.cfg
drwxr-sr-x 2 openhab openhab  4096 Sep 20 09:33 scripts
-rw-r--r-- 1 openhab openhab  1848 Sep 20 09:33 shell.init.script
-rw-r--r-- 1 openhab openhab   724 Sep 20 09:32 startup.properties
-rw-r--r-- 1 openhab openhab  5316 Sep 20 09:32 system.properties
-rw-r--r-- 1 openhab openhab  1453 Sep 20 09:33 users.properties
-rw-r--r-- 1 openhab openhab   367 Sep 20 09:33 version.properties

/opt/openhab/userdata/logs:
total 16
drwxr-sr-x 2 openhab openhab 4096 Oct  3 06:40 .
drwxr-sr-x 6 openhab openhab 4096 Oct  5 21:58 ..
-rw-r--r-- 1 openhab openhab 6700 Oct  5 21:58 openhab.log

/opt/openhab/userdata/tmp:
total 20
drwxr-sr-x 3 openhab openhab 4096 Oct  5 21:58 .
drwxr-sr-x 6 openhab openhab 4096 Oct  5 21:58 ..
drwxr-sr-x 2 openhab openhab 4096 Oct  5 21:58 instances
-rw-r--r-- 1 openhab openhab    2 Oct  5 21:58 karaf.pid
-rw-r--r-- 1 openhab openhab  847 Sep 20 09:31 README

I even tried starting up the container without any mapped volumes, copied what was in /openhab/userdata and config out of the volume in into the host directories of /opt/userdata and config.

When I tried to bring up the contain like that it went into some loop with a line about mmap error.

I just tried to change my host volumes from being on my /opt folder to another location on another hard drive and the container started up!

The only difference is that the /opt folder sits on an encrypted luks drive in a mergefs (aka unionfs) ext4 file system. Whereas the new location I tried is on an unencrypted ext4 partition on an external USB hard drive.

Is the openhab container trying to do something low level to the disk that it would care about where the host volume data is mounted?

I have a half dozen other containers mounting/mapping volumes to /opt without any problems. That is very strange. I would prefer to keep openhab’s data in /opt. Any ideas what might be happening?

I figured out what was happening with the docker installation.

Openhab cannot be installed a mergerfs/union file system because they mount options for those file systems in fstab that default to cache.files=off. Openhab uses mmap functions which need cache file memory mapping to work. You would have to set it to cache.files=partial but this would slow down your system because of double buffering on the real path and the mergerfs path.

So it is best to just install the docker container on a non-mergerfs mount path.

That is what I did and it works.

1 Like