Hi.
I am just doing the same migration process from Pi3 to DS916+
First I wanna say thanks to Rich @rlkoshak and the other guys improving the docker container and it’s documentation. I think the docker install page is a really good reference. Great work! I’m really falling in love with docker
What is missing is (of course) the syno specific stuff regarding user management. So after same try-and-error I figured out the following steps (tried it several times with oh2.3 and oh2.4 container) to get the container up and running on DSM6.2
1) Create directories
Like mentioned in the docs you need to create the directories that should be mounted in the container later on. I have set up a share on my DSM with a directory for each docker container I’m using, containing the different mounts as subdirectories, e.g. conf (see also screenshot below, ignore the .vscode and .git folders for now).
2) Set up permissions for the share
I have defined a separate docker user on DSM with write access to this docker share and no other DSM permission (user is called docker_rw
on my system). Basically you can also use your “normal” DSM user as long as this user has write access to the docker share. But I’m a fan of dedicated users for these things.
Now you have to find out the user ID of your docker user. To do so SSH into your DS. There may be different solutions to find out the ID of a linux user, I always use
cat /etc/passwd
The output is 1 line for each linux user on the system like this
docker_rw:x:1030:100:<Some-Description>:/var/services/homes/docker_rw:/sbin/nologin
where 1030
is the user ID.
3) Deploy the container using docker compose
I prefer docker compose for repeatable deployment. So let’s create the required docker-compose.yml
file in our main openhab directory on the docker share (see also screenshot below) with the following content:
version: '3'
services:
openhab_test: #name of the service
container_name: openhab_test
image: "openhab/openhab:2.4.0-amd64-debian"
restart: always
network_mode: host
volumes:
- "/etc/localtime:/etc/localtime:ro"
- "/etc/TZ:/etc/timezone:ro"
- "./addons:/openhab/addons"
- "./conf:/openhab/conf"
- "./userdata:/openhab/userdata"
environment:
USER_ID: "1030"
OPENHAB_HTTP_PORT: "18080"
OPENHAB_HTTPS_PORT: "18443"
EXTRA_JAVA_OPTS: "-Duser.timezone=Europe/Berlin"
LC_ALL: "de_DE.UTF-8"
LANG: "de_DE.UTF-8"
LANGUAGE: "de_DE.UTF-8"
devices:
- "/dev/ttyACM0:/dev/ttyACM0" # for Zwave stick
I think most of the statements are more or less self-explanatory. This is the example for my test installation so I have changed to ports. This is not necessary if you want to use the standard ports. You can set all environment variables as described on the openhab docker install page.
Important step here is to set the user ID we found out in step 2 as environment variable and NOT as user flag. This took me some time to find out as the openhab dockerhub reference says you have to do both.
This didn’t work for me and caused to container to fail with permission issues. After removing the user statement it just worked. Actually I’m not sure if this is a Synology specific issue or just an issue in the docs.
After the docker-compose.yml
file is saved go back to your Synology SSH terminal and let the magic happen:
cd /volumeX/<name_of_docker_share>/<openhab_folder>/ #example
cd /volume3/docker/openhab_test/ #real command on my system
sudo docker-compose up -d
That’s it (hopefully )
Now the container should be up and running and also visible in the docker UI on DSM. You can now stop/start/modify/delete the container from the UI as any other container created via UI.
Hint: Of course you don’t have to use docker-compose. It should work the same way with docker run ...
So, enough for now. I hope this write-up helps some of you guys to have fun with docker and openhab on your Synology.
And to the experts out there: I’m just learning docker so if you find some mistakes or room for improvement please let me know.
Cheers
Sebastian