Docker - where is openhab?

Hello,

I installed the official Docker image, and I can reach the web-interface.

However I would like the config-files to be on the hosts (not to be lost on updates and so on), and followed both the tutorial on the wiki as well as in the docker description

I installed 2.3.0-snapshot.

However I cannot find the configuration files. They are not on /opt/docker. There is a file structure on /openhab, are those the right files?

thank you
Daniel

Then you did not follow the tutorial correctly.

https://docs.openhab.org/installation/docker.html#create-the-openhab-conf-userdata-and-addon-directories.

This section has you create the folders that you will mount into the container at /opt/openhab.

The command you run in the next section assumes these folders were created and exist and have the proper permissions for the openhab user to write to. If they do then the container will populate those empty folders with the default config and other files.

When followed correctly, the config files will be in /opt/openhab/conf

I made the directories

root@homeserver:~# ls -la /data/docker/openhab/
total 4
drwxr-xr-x  5 openhab openhab   61 Mar 29 19:20 .
drwxr-xr-x 13 daniel  daniel  4096 Mar 29 17:05 ..
drwxr-xr-x  2 openhab openhab   10 Mar 29 19:20 addons
drwxr-xr-x  2 openhab openhab   10 Mar 29 19:20 conf
drwxr-xr-x  2 openhab openhab   10 Mar 29 19:20 userdata

I made the user as per Docker container description:

groupadd -g 9001 openhab
useradd -u 9001 -g openhab -r -s /sbin/nologin openhab
usermod -a -G openhab myownuser

and then started the docker container with

docker run --name openhab --net=host --tty -v /etc/localtime:/etc/localtime:ro -v /etc/timezone:/etc/timezone:ro -v /opt/openhab/conf:/data/docker/openhab/conf -v /opt/openhab/userdata:/data/docker/openhab/userdata -v /opt/openhab/addons:/data/docker/openhab/addons -p 8080 -p 8443 -p 8101 -p 5007 -d -e CRYPTO_POLICY=unlimited --restart=always openhab/openhab:2.3.0-snapshot-amd64-debian 

EDIT: I am sorry, I found my (obvious) error myself: The syntax is -v local_directory:docker_directory not the other way around.

However: when are the files populated? Even after installing bindings in PaperUI the folders are still empty, is that normal?

Thanks
Daniel

EDIT: so now the /opt/openhab is created inside docker, but all the files are still put in /openhab

The start script entrypoint.sh is the first thing that gets run when the container starts. It looks to see if /openhab/userdata and /openhab/conf is empty. If they are empty it copies over the default files and folders to those directories. Then it runs OH.

You need to map the files and folders to where they are in the container. Not where they are on the host.

So you use -v /opt/openhab/conf:/openhab/conf and -v /opt/openhab/userdata:/openhab/userdata, just like the examples on the tutorial.

https://docs.openhab.org/installation/docker.html#running-the-container-as-a-service-managed-by-docker

Ok, that took me far longer to get than it should.

Thank you