Docker and 2.5.3 : Files owner and group being changed

Hi, I am in the process of upgrading from 2.4 to 2.5.3.

I run OH on a Synology NAS in a docker container. I am installing manually rather than automatically so as to retain easy fallback capability. Image is 2.5.3-amd64-debian from official source.

I am passing alternate user_id and group_id parameters to the container, and when the container starts I can see those parameters in the log:
“Starting with openhab user id: 1026 and group id: 65536”
The files on the NAS are set with the group and user permissions above.

When OH is started, the files are all changed to have a uid and gid of 9001, which is the container default for the openhab user. All the files and the directories of addons, conf and userdata are changed.

I have not been able to figure out why this is happening, but I am not an expert on docker. I have been through the openhab docker installation instructions again, but there is nothing to indicate why this is happening. I appreciate this could be a synology/docker issue, but I though I would post here in case anyone has words of wisdom.

I suppose I could manually set up a user and group with the uid and gid of 9001 on the Synology NAS, but I prefer to do NAS config via the GUI to avoid potential problems.

Any advice / pointers apprciated!

Kind regards
Martin

What is your Docker Run command look like? You can specify UID & GID but 9001 is the default.

HI Bruce, In the Synology NAS, parameters are provided via a GUI. So I dont get to see the actual Docker Run command used. But the log file suggests all is well:

  • ‘[’ limited = unlimited ‘]’
  • rm -f /openhab/runtime/instances/instance.properties
  • rm -f /openhab/userdata/tmp/instances/instance.properties
  • NEW_USER_ID=1026
  • NEW_GROUP_ID=65536
  • echo ‘Starting with openhab user id: 1026 and group id: 65536’
    Starting with openhab user id: 1026 and group id: 65536
  • id -u openhab
  • case ${OPENHAB_VERSION} in
  • initialize_volume /openhab/conf /openhab/dist/conf
  • volume=/openhab/conf
  • source=/openhab/dist/conf
    ++ ls -A /openhab/conf
  • ‘[’ -z 'html
1 Like

Martin, did you get this to work? I’m also trying this on Synology docker. I got 2.4 to work in Docker, setting the environment variables USER_ID and GROUP_ID. I did not set NEW_USER_ID or NEW_GROUP_ID, and these did not show up like USER_ID and GROUP_ID in the docker window. I tried my same setup with 2.5.3 with your results, and also added the NEW_USER_ID and NEW_GROUP_ID variables, with the same result. Really, mine fails with a permission error because it’s trying to use the 9001.

I have to ask also, why does the openhab docker have to do strange things with the user id? Why can’t it just use normal docker controls of the user it runs with?

I thought switching to docker would make switching openhab versions easier. It was kind of pain to switch from 2.3 to 2.4 using the native synology (had to uninstall and install the new version, a couple times, and had nothing running until I got it working). So far at least, I can try a 2.5 thing and when it fails just start the 2.4 one up again.

Hi Paul, No, I did not get working the way I wanted. My main motivation was to be able to access the files outside the NAS via SMB/SFTP etc. The workaround I have used is not great - open up the permissions on the folders and files. From what I learnt, the Synology NAS manages users and groups outside the files in /etc. So any local changes to workaround the problem there would likely not persist.

As to why Docker is doing strange things with the the UserID, i don’t know. But my suspicion is that it is not a Docker issue, but a problem with the container. With a previous installation (2.5.0 as I recall) the setting of UID/GID worked as expected. I ran out of time to investigate further which would likely have meant expanding my knowledge into container details more than I care to.

I use docker because one time I used an installation script to put OH on the NAS, it failed badly. So much so that the whole NAS had to be re-built.

I am reasonably content with the use of Docker aside from the UID/GID issue. I tend not to do in-place upgrades, but copy data and then new install. It allows easy reversion to a working system if things don’t work, just by starting a different container.

Kind Regards
Martin

I was using the GUI on synology to set up the containers, and didn’t like having toe type everything over. You can export the settings, but it had extra stuff (all the environment variables) that should get carried over to the next version. I suppose it could be edited, but I decided to try out docker compose instead. Well, the container I set up with docker compose worked. I don’t know what is the problem. I used runlike to get the run commands from each. I guess it doesn’t really give the actual command, because there is extra stuff that is most definitely not from the compose command. The only difference that seems like it would even matter is the -t in the GUI case.

For the GUI case:

docker run \
        --name=openhab-253 \
        --hostname=openhab-253 \
        --env="NEW_GROUP_ID=100" \
        --env="NEW_USER_ID=1035" \
        --env="PATH=/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin" \
        --env="ARCH=x86_64" \
        --env="UBUNTU_SUITE=buster" \
        --env="DOCKER_REPO=multiarch/debian-debootstrap" \
        --env="JAVA_URL=https://cdn.azul.com/zulu/bin/zulu8.42.0.23-ca-jdk8.0.232-linux_x64.tar.gz" \
        --env="JAVA_VERSION=8" \
        --env="OPENHAB_URL=https://bintray.com/openhab/mvn/download_file?file_path=org%2Fopenhab%2Fdistro%2Fopenhab%2F2.5.3%2Fopenhab-2.5.3.zip" \
        --env="OPENHAB_VERSION=2.5.3" \
        --env="CRYPTO_POLICY=limited" \
        --env="EXTRA_JAVA_OPTS=" \
        --env="GROUP_ID=100" \
        --env="KARAF_EXEC=exec" \
        --env="LC_ALL=en_US.UTF-8" \
        --env="LANG=en_US.UTF-8" \
        --env="LANGUAGE=en_US.UTF-8" \
        --env="OPENHAB_BACKUPS=/openhab/userdata/backup" \
        --env="OPENHAB_CONF=/openhab/conf" \
        --env="OPENHAB_HOME=/openhab" \
        --env="OPENHAB_HTTP_PORT=8080" \
        --env="OPENHAB_HTTPS_PORT=8443" \
        --env="OPENHAB_LOGDIR=/openhab/userdata/logs" \
        --env="OPENHAB_USERDATA=/openhab/userdata" \
        --env="USER_ID=1035" \
        --env="JAVA_HOME=/usr/lib/jvm/default-jvm" \
        --volume="/volume1/SmartHome/timezone:/etc/timezone:ro" \
        --volume="/volume1/SmartHome/openHAB2.5/userdata:/openhab/userdata:rw" \
        --volume="/volume1/SmartHome/openHAB2.5/conf:/openhab/conf:rw" \
        --volume="/volume1/SmartHome/openHAB2.5/addons:/openhab/addons:rw" \
        --volume="/openhab/userdata" \
        --volume="/openhab/conf" \
        --volume="/openhab/addons" \
        --network=host \
        --restart=no \
        --label org.label-schema.build-date="2020-04-09T14:28:24Z" \
        --label org.label-schema.vcs-type="Git" \
        --label org.label-schema.version="2.5.3" \
        --label org.label-schema.license="EPL-2.0" \
        --label org.label-schema.description="An open source, technology agnostic home automation platform" \
        --label org.label-schema.docker.dockerfile="/Dockerfile" \
        --label org.label-schema.vcs-url="https://github.com/openhab/openhab-docker.git" \
        --label org.label-schema.vcs-ref="7c14267852b7f0cf44b5891b3f55b343282ffc4c" \
        --label org.label-schema.url="https://www.openhab.com/" \
        --label org.label-schema.vendor="openHAB Foundation e.V." \
        --label maintainer="openHAB <info@openhabfoundation.org>" \
        --label org.label-schema.name="openHAB" \
        --detach=true \
        -t \
        openhab/openhab:2.5.3 \
        gosu openhab tini -s ./start.sh

Then the compose case:

docker run \
        --name=openhab-dc \
        --hostname=Synology \
        --env="PATH=/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin" \
        --env="ARCH=x86_64" \
        --env="UBUNTU_SUITE=buster" \
        --env="DOCKER_REPO=multiarch/debian-debootstrap" \
        --env="JAVA_URL=https://cdn.azul.com/zulu/bin/zulu8.42.0.23-ca-jdk8.0.232-linux_x64.tar.gz" \
        --env="JAVA_VERSION=8" \
        --env="OPENHAB_URL=https://bintray.com/openhab/mvn/download_file?file_path=org%2Fopenhab%2Fdistro%2Fopenhab%2F2.5.3%2Fopenhab-2.5.3.zip" \
        --env="OPENHAB_VERSION=2.5.3" \
        --env="CRYPTO_POLICY=limited" \
        --env="EXTRA_JAVA_OPTS=" \
        --env="GROUP_ID=100" \
        --env="KARAF_EXEC=exec" \
        --env="LC_ALL=en_US.UTF-8" \
        --env="LANG=en_US.UTF-8" \
        --env="LANGUAGE=en_US.UTF-8" \
        --env="OPENHAB_BACKUPS=/openhab/userdata/backup" \
        --env="OPENHAB_CONF=/openhab/conf" \
        --env="OPENHAB_HOME=/openhab" \
        --env="OPENHAB_HTTP_PORT=8080" \
        --env="OPENHAB_HTTPS_PORT=8443" \
        --env="OPENHAB_LOGDIR=/openhab/userdata/logs" \
        --env="OPENHAB_USERDATA=/openhab/userdata" \
        --env="USER_ID=1035" \
        --env="JAVA_HOME=/usr/lib/jvm/default-jvm" \
        --volume="/volume1/SmartHome/timezone:/etc/timezone:ro" \
        --volume="/volume1/SmartHome/openHAB2.5/addons:/openhab/addons:rw" \
        --volume="/volume1/SmartHome/openHAB2.5/userdata:/openhab/userdata:rw" \
        --volume="/volume1/SmartHome/openHAB2.5/conf:/openhab/conf:rw" \
        --volume="/etc/timezone" \
        --volume="/openhab/userdata" \
        --volume="/openhab/conf" \
        --volume="/openhab/addons" \
        --network=host \
        --restart= \
        --label com.docker.compose.version="1.24.0" \
        --label org.label-schema.vcs-type="Git" \
        --label com.docker.compose.container-number="1" \
        --label org.label-schema.vendor="openHAB Foundation e.V." \
        --label org.label-schema.build-date="2020-04-09T14:28:24Z" \
        --label org.label-schema.license="EPL-2.0" \
        --label com.docker.compose.project="openhab-25" \
        --label org.label-schema.description="An open source, technology agnostic home automation platform" \
        --label com.docker.compose.config-hash="0869bd260fe6328fe5518ef7accb01fa7fa8d4d642e917abb639c81563ee3b6f" \
        --label org.label-schema.docker.dockerfile="/Dockerfile" \
        --label com.docker.compose.oneoff="False" \
        --label org.label-schema.vcs-url="https://github.com/openhab/openhab-docker.git" \
        --label org.label-schema.vcs-ref="7c14267852b7f0cf44b5891b3f55b343282ffc4c" \
        --label org.label-schema.url="https://www.openhab.com/" \
        --label com.docker.compose.service="openhab" \
        --label org.label-schema.version="2.5.3" \
        --label maintainer="openHAB <info@openhabfoundation.org>" \
        --label org.label-schema.name="openHAB" \
        --detach=true \
        openhab/openhab:2.5.3 \
        gosu openhab tini -s ./start.sh

This is my compose yml file:

version: '3.3'
services:
    openhab:
        container_name: openhab-dc
        environment:
            - GROUP_ID=100
            - USER_ID=1035
        volumes:
            - '/volume1/SmartHome/timezone:/etc/timezone:ro'
            - '/volume1/SmartHome/openHAB2.5/userdata:/openhab/userdata:rw'
            - '/volume1/SmartHome/openHAB2.5/conf:/openhab/conf:rw'
            - '/volume1/SmartHome/openHAB2.5/addons:/openhab/addons:rw'
        network_mode: host
        image: 'openhab/openhab:2.5.3'