Docker Restarting: KARAF_ETC is not valid: /openhab/userdata/etc

This error is still a sly bastard - see EDIT 2 at the end of my main post :grimacing:

I tried so many different solutions I have since forgotten exactly what the solution was, but I do remember that it wasn’t directly related to the userdata folder. I recall it was one of the other folders referenced, and what I did was edit the line in the docker to point to the correct location and it worked. I have since given up on the whole project and reverted back to my old install on the Pi. I started running into permissions problems, and the inability to use my existing items, things, rules, etc files so gave up. I’m going to mark this as solved. Thanks everyone for your help.

Hello all,
I’ve run into the same issue (KARAF_ETC is not valid: /openhab/userdata/etc) despite pre-creating the conf, addons & userdata directories. I also pre-created the username as openhab (uid and gid 2022) and passed these in the environment variables

environment:
    USER_ID: "2022"
    GROUP_ID: "2022"

I also ran chown -R openhab:openhab on the openhab directory so that conf, userdata and addons as well as the parent directory are owned by openhab:openhab.

What else am I missing?
It complained about missing version.properties in userdata/etc so I copied it from an existing installation and ended up with the second error.

I don’t know what I’m missing. Please help

I don’t know what I am missing either.
What operating system?

How are you starting the container? If you are using Docker run post your command. If you are using Docker-compose post the file for that.

We cannot help with no data.

@Bruce_Osborne. Thank you so much for your time. I’m using docker-compose and here is the relevant service part

  openhab:
    image: openhab/openhab:latest
    restart: unless-stopped
    volumes:
      - /etc/localtime:/etc/localtime:ro
      - /etc/timezone:/etc/timezone:ro
      - $PWD/conf/openhab:/openhab/conf
      - $PWD/data/openhab/userdata:/openhab/userdata
      - $PWD/data/openhab/addons:/openhab/addons
      - $PWD/logs/openhab:/openhab/userdata/logs
    networks:
      - main
    environment:
        USER_ID: "2022"
        GROUP_ID: "2022"

Edit: The OS is Debian 10

Are you running the recommended Docker Community Edition or the default Debian packages?

Does UID 2022 have full write access to $PWD and its subdirectories? Can that user create directories there?

I’m using the version of docker installed by the script on the docker website.

Yes, user 2022 has full access to the directories. In fact, it creates folders etc under conf such as items, sites etc

drwxr-xr-x 2 openhab openhab 4096 Aug  3 20:16 addons
drwxr-xr-x 2 openhab openhab 4096 Aug  3 21:23 userdata

Just attempted to create a container now with just the empty mandatory directories

openhab        | Initializing empty volume /openhab/conf ...
openhab        | + '[' -z '' ']'
openhab        | + echo 'Initializing empty volume /openhab/conf ...'
openhab        | + cp -av /openhab/dist/conf/. /openhab/conf/
openhab        | '/openhab/dist/conf/./html' -> '/openhab/conf/./html'
openhab        | '/openhab/dist/conf/./html/index.html' -> '/openhab/conf/./html/index.html'
openhab        | '/openhab/dist/conf/./html/readme.txt' -> '/openhab/conf/./html/readme.txt'
openhab        | '/openhab/dist/conf/./icons' -> '/openhab/conf/./icons'
openhab        | '/openhab/dist/conf/./icons/classic' -> '/openhab/conf/./icons/classic'
openhab        | '/openhab/dist/conf/./icons/classic/readme.txt' -> '/openhab/conf/./icons/classic/readme.txt'
openhab        | '/openhab/dist/conf/./items' -> '/openhab/conf/./items'
openhab        | '/openhab/dist/conf/./items/readme.txt' -> '/openhab/conf/./items/readme.txt'
openhab        | '/openhab/dist/conf/./persistence' -> '/openhab/conf/./persistence'
openhab        | '/openhab/dist/conf/./persistence/readme.txt' -> '/openhab/conf/./persistence/readme.txt'
openhab        | '/openhab/dist/conf/./rules' -> '/openhab/conf/./rules'
openhab        | '/openhab/dist/conf/./rules/readme.txt' -> '/openhab/conf/./rules/readme.txt'
openhab        | '/openhab/dist/conf/./scripts' -> '/openhab/conf/./scripts'
openhab        | '/openhab/dist/conf/./scripts/readme.txt' -> '/openhab/conf/./scripts/readme.txt'
openhab        | '/openhab/dist/conf/./services' -> '/openhab/conf/./services'
openhab        | '/openhab/dist/conf/./services/addons.cfg' -> '/openhab/conf/./services/addons.cfg'
openhab        | '/openhab/dist/conf/./services/readme.txt' -> '/openhab/conf/./services/readme.txt'
openhab        | '/openhab/dist/conf/./services/runtime.cfg' -> '/openhab/conf/./services/runtime.cfg'
openhab        | '/openhab/dist/conf/./sitemaps' -> '/openhab/conf/./sitemaps'
openhab        | '/openhab/dist/conf/./sitemaps/readme.txt' -> '/openhab/conf/./sitemaps/readme.txt'
openhab        | '/openhab/dist/conf/./sounds' -> '/openhab/conf/./sounds'
openhab        | '/openhab/dist/conf/./sounds/barking.mp3' -> '/openhab/conf/./sounds/barking.mp3'
openhab        | '/openhab/dist/conf/./sounds/doorbell.mp3' -> '/openhab/conf/./sounds/doorbell.mp3'
openhab        | '/openhab/dist/conf/./things' -> '/openhab/conf/./things'
openhab        | '/openhab/dist/conf/./things/readme.txt' -> '/openhab/conf/./things/readme.txt'
openhab        | '/openhab/dist/conf/./transform' -> '/openhab/conf/./transform'
openhab        | '/openhab/dist/conf/./transform/de.map' -> '/openhab/conf/./transform/de.map'
openhab        | '/openhab/dist/conf/./transform/en.map' -> '/openhab/conf/./transform/en.map'
openhab        | '/openhab/dist/conf/./transform/readme.txt' -> '/openhab/conf/./transform/readme.txt'
openhab        | + initialize_volume /openhab/userdata /openhab/dist/userdata
openhab        | + volume=/openhab/userdata
openhab        | + source=/openhab/dist/userdata
openhab        | ++ ls -A /openhab/userdata
openhab        | + '[' -z logs ']'
openhab        | ++ cmp /openhab/userdata/etc/version.properties /openhab/dist/userdata/etc/version.properties
openhab        | cmp: /openhab/userdata/etc/version.properties: No such file or directory
openhab        | + '[' '!' -z ']'
openhab        | + chown -R openhab:openhab /openhab

Notice the error about version.properties being non-existent. As I said, if I copy one from an existing installation and restart the container I get the java null error mentioned in the OP

There is no script on the Docker website. Just tagged containers. I have been testing the latest 2.5.7 version on Debian 10 with no issues.

In fact, I just installed it fresh a minute ago.Perhaps you got a bad download? Try stopping & uninstalling the container

docker stop openhab
docker system prune --all

And then run docker-compose again to download a fresh copy.

1 Like

I’ve tried that and I’m still getting the same thing. Also tried it in a Debian VM and RPi and I get the same thing.

openhab        | + initialize_volume /openhab/conf /openhab/dist/conf
openhab        | + volume=/openhab/conf
openhab        | + source=/openhab/dist/conf
openhab        | ++ ls -A /openhab/conf
openhab        | + '[' -z '' ']'
openhab        | + echo 'Initializing empty volume /openhab/conf ...'
openhab        | + cp -av /openhab/dist/conf/. /openhab/conf/
openhab        | Initializing empty volume /openhab/conf ...
openhab        | '/openhab/dist/conf/./html' -> '/openhab/conf/./html'
openhab        | '/openhab/dist/conf/./html/index.html' -> '/openhab/conf/./html/index.html'
openhab        | '/openhab/dist/conf/./html/readme.txt' -> '/openhab/conf/./html/readme.txt'
openhab        | '/openhab/dist/conf/./icons' -> '/openhab/conf/./icons'
openhab        | '/openhab/dist/conf/./icons/classic' -> '/openhab/conf/./icons/classic'
openhab        | '/openhab/dist/conf/./icons/classic/readme.txt' -> '/openhab/conf/./icons/classic/readme.txt'
openhab        | '/openhab/dist/conf/./items' -> '/openhab/conf/./items'
openhab        | '/openhab/dist/conf/./items/readme.txt' -> '/openhab/conf/./items/readme.txt'
openhab        | '/openhab/dist/conf/./persistence' -> '/openhab/conf/./persistence'
openhab        | '/openhab/dist/conf/./persistence/readme.txt' -> '/openhab/conf/./persistence/readme.txt'
openhab        | '/openhab/dist/conf/./rules' -> '/openhab/conf/./rules'
openhab        | '/openhab/dist/conf/./rules/readme.txt' -> '/openhab/conf/./rules/readme.txt'
openhab        | '/openhab/dist/conf/./scripts' -> '/openhab/conf/./scripts'
openhab        | '/openhab/dist/conf/./scripts/readme.txt' -> '/openhab/conf/./scripts/readme.txt'
openhab        | '/openhab/dist/conf/./services' -> '/openhab/conf/./services'
openhab        | '/openhab/dist/conf/./services/addons.cfg' -> '/openhab/conf/./services/addons.cfg'
openhab        | '/openhab/dist/conf/./services/readme.txt' -> '/openhab/conf/./services/readme.txt'
openhab        | '/openhab/dist/conf/./services/runtime.cfg' -> '/openhab/conf/./services/runtime.cfg'
openhab        | '/openhab/dist/conf/./sitemaps' -> '/openhab/conf/./sitemaps'
openhab        | '/openhab/dist/conf/./sitemaps/readme.txt' -> '/openhab/conf/./sitemaps/readme.txt'
openhab        | '/openhab/dist/conf/./sounds' -> '/openhab/conf/./sounds'
openhab        | '/openhab/dist/conf/./sounds/barking.mp3' -> '/openhab/conf/./sounds/barking.mp3'
openhab        | '/openhab/dist/conf/./sounds/doorbell.mp3' -> '/openhab/conf/./sounds/doorbell.mp3'
openhab        | '/openhab/dist/conf/./things' -> '/openhab/conf/./things'
openhab        | '/openhab/dist/conf/./things/readme.txt' -> '/openhab/conf/./things/readme.txt'
openhab        | '/openhab/dist/conf/./transform' -> '/openhab/conf/./transform'
openhab        | '/openhab/dist/conf/./transform/de.map' -> '/openhab/conf/./transform/de.map'
openhab        | '/openhab/dist/conf/./transform/en.map' -> '/openhab/conf/./transform/en.map'
openhab        | '/openhab/dist/conf/./transform/readme.txt' -> '/openhab/conf/./transform/readme.txt'
openhab        | + initialize_volume /openhab/userdata /openhab/dist/userdata
openhab        | + volume=/openhab/userdata
openhab        | + source=/openhab/dist/userdata
openhab        | ++ ls -A /openhab/userdata
openhab        | + '[' -z logs ']'
openhab        | ++ cmp /openhab/userdata/etc/version.properties /openhab/dist/userdata/etc/version.properties
openhab        | cmp: /openhab/userdata/etc/version.properties: No such file or directory
openhab        | + '[' '!' -z ']'
openhab        | + chown -R openhab:openhab /openhab
openhab        | + sync
openhab        | + '[' -d /etc/cont-init.d ']'
openhab        | + sync
openhab        | + '[' false == false ']'
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        | KARAF_ETC is not valid: /openhab/userdata/etc

There’s also a few lines of text about this and other common issues in the documentation that may help.

2 Likes

Thanks a lot for that. I’ve gone through everything again and realised that by mapping teh above for logs I’m introducing a new folder that the OH image is not expecting and fails.

Surely this is a bug and some logic could be introduced to overcome these things so that the image is not so sensitive?!

If the user does not follow the documentation and permit proper permissions, the user IS the bug.

That’s how Docker volumes are initialized by default. If there is any data in the volume it is used. If there is no data, the volume is initialized with the initial data.

Just to add some details. I don’t think that it is an issue that the image doesn’t expect that folder to be mapped in. The problem is the user that openHAB runs as inside the container doesn’t have permission to read/write to that folder. There is nothing that could be done inside the image to address this. This is a case where you, as the user, need to have a bit deeper of an understanding on how Docker and Linux works.

If you want to deviate from the default instructions where you map the whole userdata folder into the container by mapping each individual subfolder isntead that’s perfectly fine and doable. You just have to get the file/folder permissions right.

hi @rlkoshak
The logs folder was being mounted as a folder within userdata with the account being passed to OpenHAB in the environment (UID and GUID 2022) having full rw access to both userdata and the logs folder the only thing that is different to what is “expected” is that the container was started with the following empty folders with full permissions:

/openhab/userdata
/openhab/userdata/logs
/openhab/addons

It seems to be expecting just
/openhab/userdata
/openhab/addons

Why does the mere existence of an empty folder under “userdata” called “logs” cause a problem given that the permissions are correct?

This is perhaps were my understanding of Docker and the way the image interacts with it is lacking.

The entrypoint script probably tries to create the logs folder and because it already exists fails to do so. This would only be a problem the very first time the container starts with an empty userdata folder. Each subsequent start of a container with that userdata folder will see that it’s already populated and not try to create folders that already exists.

This should be fixable in the script but I question whether it’d be worth the effort. It’s an error that only occurs under this exact situation which should not be a problem when following the instructions. But I know that a PR would appreciated if one were submitted.

Hey, I see the same error on my new installation, but the problem was that /openhab/userdata was a non-empty dir… so, first, cleanup the dir. Another problem can be permissions on /openhab/userdata, because when its run, checks the version installed:

++ cmp /openhab/userdata/etc/version.properties /openhab/dist/userdata/etc/version.properties
cmp: /openhab/userdata/etc/version.properties: No such file or directory

If this file above don’t exist, you have a dirty or not finished initial setup.

I hope this can help :slight_smile:

That did the trick! Thank´s a lot! Otherwise the container won´t start…

1 Like

What works for me, when I encounter this error was explicitly setting the same permissions as Openhab does during init:
(chown ommited)

sudo chmod -R 755 openhab/userdata 
sudo chmod -R 755 openhab/conf

This is somewhat strange as the folders had less restrictive permissions before(777+). It looks like the init script or one of it’s components checks for this explicit mask and fails if is not exactly 755.