Install & maintain openHAB on Raspi in Docker together with Mosquitto, Duplicati, influxDB, Samba etc - Step by step instruction

Minor update on the Duplicati-part (forcing update to latest version and adding enviroment variable for the (at least in my case) now-mandatory password.

Thank you for your helpful work.
I used your docker-compose.yml with samba, mosquitto, frontail and openhab.
Opening \docker on windows shows the shares but I do not have write permissions, e.g. to configure mosquitto by changing mosquitto.conf.
Do I have to add a user with write access? Possibly using commands like:

>command: '-w PRIVAT -s "scaner_ro;/mnt2;yes;yes;no;alice,bob;none;none;Scaner Volume RO" -s "scaner_rw;/mnt2;yes;no;no;alice;none;none;Scaner Volume RW" -u "alice;pwa" -u "bob;pwb" -n -p'

mentioned in
https://forums.docker.com/t/issue-with-samba-dperson-config/125072/3

Short answer: I don’t know.

From what I know, my configuration should work without username/password. Sometimes it does, sometimes it doesn’t (but without me changing anything, so also without me being able to reproduce). Maybe it has to do with what’s mentioned in the link you provided?

To counter this, I’ve also tried adding specific username/password-details wich, sometimes work, and sometimes doesn’t.

So in case you find out more, feel free to let me know so that I can test on my end and eventually edit my description at the very top.

I deleted all containers, images, corresponding volumes and started and used this docker-compose.yml:

## Version, die openhab installiert und restore.zip reinkopiert - das hat geklappt!!!
## ErgÀnzung: Samba
services:
  openhab:
    image: "openhab/openhab:4.3.1"
    container_name: openhab
    depends_on:
      - mosquitto
    restart: always
    network_mode: host
    volumes:
      - "/etc/localtime:/etc/localtime:ro"
      - "/etc/timezone:/etc/timezone:ro"
      - data_openhab_conf:/openhab/conf
      - data_openhab_addons:/openhab/addons
      - data_openhab_userdata:/openhab/userdata
      - "./restore:/openhab/restore"
      - "./backup:/openhab/backup"
    command: "bash -c 'if [ -e /openhab/restore/restore.zip ]; then echo y |/openhab/runtime/bin/restore /openhab/restore/restore.zip ; fi; exec tini -s ./start.sh server'"
    environment:
      CRYPTO_POLICY: "unlimited"
      EXTRA_JAVA_OPTS: "-Duser.timezone=Europe/Berlin"
      OPENHAB_HTTP_PORT: "8080"
      OPENHAB_HTTPS_PORT: "8443"

  frontail:
    image: welteki/frontail-openhab:latest
    container_name: frontail
    restart: always
    ports:
      - "9001:9001"
    volumes:
      - /var/lib/docker/volumes/openhab_data_openhab_userdata/_data:/openhab/userdata:ro \

  mosquitto:
    image: eclipse-mosquitto:latest
    container_name: mosquitto
    restart: always
    volumes:
      - data_mosquitto_config:/mosquitto/config
      - data_mosquitto_data:/mosquitto/data
      - data_mosquitto_log:/mosquitto/log
    ports:
      - 1883:1883
      - 8883:8883
    environment:
      TZ: 'Europe/Berlin'
    networks:
      app-nw:
        aliases:
          - mqtt

  samba:
    image: dperson/samba
    container_name: samba
    restart: always
    ports:
      - "137:137/udp"
      - "138:138/udp"
      - "139:139/tcp"
      - "445:445/tcp"
    read_only: false
    stdin_open: true
    healthcheck:
      disable: true
    environment:
    - TZ='Europe/Berlin'
    - PUID=9001
    - PGID=9001
    - WORKGROUP=workgroup
    - PERMISSIONS=true
    - RECYCLE=false
    - SHARE1=openhab_conf;/shares/openhab_conf;yes;no;yes;all;all;all;
    - SHARE2=openhab_addons;/shares/openhab_addons;yes;no;yes;all;all;all;
    - SHARE3=openhab_userdata;/shares/openhab_userdata;yes;no;yes;all;all;all;
    - SHARE4=mosquitto_config;/shares/mosquitto_config;yes;no;yes;all;all;all;
    - SHARE5=mosquitto_log;/shares/mosquitto_log;yes;no;yes;all;all;all;
    - SHARE6=docker;/shares/docker;yes;no;yes;all;all;all;
    - SHARE7=log;/shares/log;yes;no;yes;all;all;all;
    volumes:
      - data_openhab_conf:/shares/openhab_conf
      - data_openhab_addons:/shares/openhab_addons
      - data_openhab_userdata:/shares/openhab_userdata
      - data_mosquitto_config:/shares/mosquitto_config
##    command: '-w PRIVAT -s "mosq_ro;/shares/mosquitto_config;yes;yes;no;openhabian;none;none;Mosquitto Config RO" -s "mosq_rw;/shares/mosquitto_config;yes;no;no;alice;none;none;Mosquit>      - data_mosquitto_log:/shares/mosquitto_log
      - /docker:/shares/docker
      - /var/log:/shares/log

volumes:
  data_openhab_conf:
  data_openhab_addons:
  data_openhab_userdata:
  data_mosquitto_config:
  data_mosquitto_data:
  data_mosquitto_log:

networks:
  app-nw:
    internal: false
    driver: bridge
    driver_opts:
      com.docker.network.bridge.name: app-openhab4
  backend-nw:
    internal: true
    driver: bridge
    driver_opts:
      com.docker.network.bridge.name: be-openhab4


Result:
I have rw-access to

docker
log
mosquitto_config
mosquitto_log

and only ro-access to

openhab_addons
openhab_conf
openhab_userdata

Thx. Will check in case I find some time and then maybe adjust the .yml above accordingly.

I also just needed access to my shares again, so I reactivated r/w access again (which I deactivated some time back because it did not work anymore). Now it works again (for some reason / don’t know for how long). Anyway, have a look at my user-definition in the .yml above. Maybe it helps you as well.

Sorry @Vaclav_Provaznik, somehow missed this back then. In case it’s still relevant: You can access influxdb quite nicely via chronograf (hence also included in my .yml above). I once wrote a short tutorial on this (see here).

Just a word of warning. I found Samba container interfering with openhab during startup. It locks files and causes strange errors. Its a race condition too, so the errors may be there or not and they may vary !
If you mapped oh folders for access with samba that is.

Thanks. Good to know. I believe these errors happen even though no user is already access files during startup via Samba, correct?

Isn’t samba pre-installed on openHABian? Then this should happen there as well?

Yes , it happens during startup. It gives you permission denied errors during samba startup even if noone accesses any files.

After that all is back to normal.
I ran Samba as docker so i do not know about Openhabian.
Maybe it can be fixed by delaying either container.

I succeeded with the following docker compose, just for openhab, mosquitto, frontail and samba:

services:
  openhab:
    image: "openhab/openhab:4.3.1"
    container_name: openhab
    depends_on:
      - mosquitto
    restart: always
    network_mode: host
    volumes:
      - "/etc/localtime:/etc/localtime:ro"
      - "/etc/timezone:/etc/timezone:ro"
      - data_openhab_conf:/openhab/conf
      - data_openhab_addons:/openhab/addons
      - data_openhab_userdata:/openhab/userdata
      - "./restore:/openhab/restore"
      - "./backup:/openhab/backup"
    command: "bash -c 'if [ -e /openhab/restore/restore.zip ]; then echo y |/openhab/runtime/bin/restore /openhab/restore/restore.zip ; fi; exec tini -s ./start.sh server'"
    environment:
      CRYPTO_POLICY: "unlimited"
      EXTRA_JAVA_OPTS: "-Duser.timezone=Europe/Berlin"
      OPENHAB_HTTP_PORT: "8080"
      OPENHAB_HTTPS_PORT: "8443"

  frontail:
    image: welteki/frontail-openhab:latest
    container_name: frontail
    restart: always
    ports:
      - "9001:9001"
    volumes:
      - /var/lib/docker/volumes/openhab_data_openhab_userdata/_data:/openhab/userdata:ro

  mosquitto:
    image: eclipse-mosquitto:latest
    container_name: mqtt5
    restart: always
    volumes:
      - /usr/local/mosquitto/mosquitto.conf:/mosquitto/config/mosquitto.conf
      - data_mosquitto_config:/mosquitto/config
      - data_mosquitto_data:/mosquitto/data
      - data_mosquitto_log:/mosquitto/log
    ports:
      - "1883:1883"
      - "8883:8883"
    volumes:
      - /usr/local/samba/smb.conf:/etc/samba/smb.conf
      - /shares:/storage
      - data_openhab_conf:/storage/openhab_conf
      - data_openhab_addons:/storage/openhab_addons
      - data_openhab_userdata:/storage/openhab_userdata
      - data_mosquitto_config:/storage/mosquitto_config
      - data_mosquitto_data:/storage/mosquitto_data
      - data_mosquitto_log:/storage/mosquitto_log
      - /var/log:/storage/log
volumes:
  data_openhab_conf:
  data_openhab_addons:
  data_openhab_userdata:
  data_mosquitto_config:
  data_mosquitto_data:
  data_mosquitto_log:

networks:
  app-nw:
    internal: false
    driver: bridge
    driver_opts:
      com.docker.network.bridge.name: app-openhab4

The command part copies a backup of my openhab in a dockerless environment into the openhab container.

To get the permissions in samba I used the following smb.conf:

> [global]
>   workgroup = WORKGROUP
>   wins support = yes
>   dns proxy = no
>   security = user
>   passdb backend = tdbsam
>   server min protocol = SMB2
>   server string = samba
>   idmap config * : range = 3000-7999
>   security = user
>   server min protocol = SMB2
>   
>   # disable printing services
>   load printers = no
>   printing = bsd
>   printcap name = /dev/null
>   disable spoolss = yes
> 
> [homes]
> comment = Home Directories
> valid users = %S, %D%w%S
> browseable = No
> read only = No
> inherit acls = Yes
> [Data]
>         path = /storage
>         comment = Shared
>         valid users = @smb
>         browseable = yes
>         writable = yes
>         read only = no
>         force user = root
>         force group = root
> 
> [openHAB-conf]
>   path = /storage/openhab_conf
>   comment = Shared
>   valid users = @smb
>   browsable = yes
>   writable = yes
>   read only = no
>   force user = root
>   force group = root
 [openHAB-addons]
  path = /storage/openhab_addons
  comment = Shared
  valid users = @smb
  browseable = yes
  writable = yes
  read only = no
  force user = root
  force group = root

[openHAB-userdata]
  path = /storage/openhab_userdata
  comment = Shared
  valid users = @smb
  browseable = yes
  writable = yes
  read only = no
  force user = root
  force group = root

[mosquitto-config]
  path = /storage/mosquitto_config
  comment = Shared
  valid users = @smb
  browseable = yes
  writable = yes
  read only = no
  force user = root
  force group = root

[mosquitto-log]
  path = /storage/mosquitto_log
  comment = Shared
  valid users = @smb
  browseable = yes
  writable = yes
  read only = no
  force user = root
  force group = root

[log]
  path = /storage/log
  comment = Shared
  valid users = @smb
  browseable = yes
  writable = yes
  read only = no
  force user = root
  force group = root