It did piss me off that I got almost always error messages when I tried to set up a new docker based openHAB installation - and I haven’t found a real solution for that in this forum. So I did run a few tests to find out what I did almost always wrong and very seldom right.
After having initialized a new openHAB container I run docker-compose ps a few times to see if my container is ‘UP’ - the first indicator that something is wrong is when I get ‘RESTARTING’ instead…
After that I run docker logs <container name> and see two possible error messages - either:
...
KARAF_ETC is not valid: /openhab/userdata/etc
or
Launching the openHAB runtime...
null
Error occurred shutting down framework: java.lang.NumberFormatException: null
java.lang.NumberFormatException: null
at java.lang.Integer.parseInt(Integer.java:542)
at java.lang.Integer.parseInt(Integer.java:615)
at org.apache.karaf.main.ConfigProperties.<init>(ConfigProperties.java:235)
at org.apache.karaf.main.Main.updateInstancePidAfterShutdown(Main.java:227)
at org.apache.karaf.main.Main.main(Main.java:192)
In the end I found out that I need to:
create the conf, addons & userdata folders before the first start of the container
but I have to keep them empty before first start of the container
have to set these folders in the container configuration
have to set ownership for a user of my choice to the parent folder and all contained files & folders (sudo chown -R /opt/openhab)
have to set the UID & GID parameters for the container to the user I did choose before
can copy my existing configuration into the conf folder after the first successful start of the container (remember to set ownership)
On a sidenote I found out that I cause error one if I have not precreated the conf, addons & userdata folder and error two if I precreate the folder /userdata/etc/
And for the interested ones - these where my tests:
~/test1: no precreated folders, no chown / chmod, u/gid set to 1000 (main user)
~/test2: no precreated folders, chown -R 1000:1000, u/gid set to 1000
~/test3: no precreated folders, chown -R 9001:9001, u/gid set to 1000 (9001 being the default uid if no uid is set for the openHAB image)
b. stop - create userdata/etc/ - start again
~/test4: no precreated folders, chown -R 9001:9001, u/gid set to 9001
b. stop - create userdata/etc/ - start again
~/test5: no precreated folders, chmod -R 777, u/gid set to 1000
b. remove container - create userdata/etc/ - start again
~/test6: no precreated folders, chmod -R 777, chown -R 9001:9001, u/gid set to 9001
b. remove container - create userdata/etc/ - start again
/opt/openhab7: create user openhab7, precreated folders, chown -R openhab7:openhab7, u/gid set to openhab7’s
~/test8: precreated folders (./conf, …), chown -R openhab7:openhab7, u/gid set to openhab7’s
~/test9: precreated folders in subfolder (./openhab/conf, ./openhab/addons, …), chown -R openhab7:openhab7, u/gid set to openhab7’s
~/test10: precreated folders in subfolder, no chown / chmod, u/gid set to 1000
EDIT: error fixes
EDIT 2:
I’m just setting up openHAB via docker on a new server - and somehow my 10. test case doesn’t work anymore for me (did not go through the work of testing them all again). What did work was the following:
situation as described in tc 10
starting the docker container
getting the now well known error KARAF_ETC is not valid: /openhab/userdata/etc when running docker logs openhab
stopping the container (just stopping the container, not deleting said container)
deleting the folder and subfolders for the openhab container (just the folder for the openhab container, not the root folder holding my docker-compose.yml)
I have not tried OH with Docker but if this is a working guide for set up then maybe move it to the tutorials category and throw in any other relevant info for Docker noobs.
@Bruce_Osborne: You are right - the official guide states that you should create these folders, but:
the guide doesn’t state that it is mandatory to create these folders - other docker images create the folders themself if you mention them in the container configuration
the guide doesn’t mention that you should not copy your existing configuration into the conf folder before the first start of the container
the error messages don’t point you at the problem at all
In my eyes that behavior is a derivation from the standard docker image behavior (in my limited experience) and the derivation is not mentioned in the documentation.
It seems like that is a bug and not intentional behavior - lets see what the developers think about it: https://github.com/openhab/openhab-docker/issues/275
I would think this behavior is a bug (I opened an issue on GitHub), if the developers of the image agree, it should be fixed and this workaround shouldn’t be necessary anymore.
That did make the error so frustrating - the first time I did set up a docker based openHAB installation I followed the guide step for step and was successful.
When I got a bit more experienced and did some changes to my setup I did run into these troubles most of the time but not always…
While it is a valid argument that one should follow directions on the openhab website, I chose to follow the directions on the actual docker openhab website instead. I thought that the docker would be specific for the container, while the openhab website could be awaiting change. Nowhere on the docker website does it mention creating folders.
In either case, I want to say thank you to Felix for all his very informative help, but in the end it did not work. I have, and continue to think that I now have a corrupted basic install of the foundation OpenMediaVault because of my earlier screw up trying to upgrade openhab.
I am about to format my OMV drive and reload the whole thing. I’ll let you know if the reload works.
This is extremely aggravating! I have completely reloaded my server with Openmediavault (it is updated and running smoother so that is a plus) and my first new Docker is supposed to be Openhab.
I created the three folders as instructed in the /opt directory (see pic).
Have you also set ownership recursively to your openhab-user (chown -R openhab:openhab Docker_Openhab) and set the uid & gid for the openhab container to that of your openhab user?
Hi Felix, and thanks again for your perseverance, I appreciate both your and Bruce’s help. Now I am not sure. I have performed the chown operation as described, however I am unaware of “set the uid & gid for the openhab container”. Isn’t that the same as chown?
Probably in the section ‚Environment Variables‘? These ID‘s have to be the same as the uid & gid of your openhab user. Under Linux you use the command id openhab to get these values - I don’t know how it works in your application