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

frontail docker command:
/bin/sh -c frontail --disable-usage-stats --ui-highlight --ui-highlight-preset /usr/local/lib/node_modules/frontail/preset/${FRONTAIL_THEME}.json --theme ${FRONTAIL_THEME} -l 2000 -n 200 ${FRONTAIL_OPTS} /var/log/openhab/events.log /var/log/openhab/openhab.log

Hi!
Can you write how upgrade to OH 4?

The part

image: openhab/openhab:latest

which is already in there should do the trick, doesnā€™t it? At least in my case it worked.

Hi!
Iā€™m trying to do your same configuration but with influxdb v2 and Iā€™m having problems with influx persistence.
Can someone help me?

I know that, at some point in time, I have to do the switch as well and then update the instruction above. But so far I have not yet started this.

If youā€™ve had any success, let me know.

Hi, Iā€™m currently running OH 4.1.1, influxDB2 2.7.5, Grafana 10.2.3 + Portainer + Duplicati. All dockerized. Production still on old notebook Windows, VirtualBox with Ubuntu, docker_compose stack, updating occasionally. I am playing with RPI and better management (all from to portaine, but I donā€™t have much time to complete and migrate, so waiting for an ā€œeventā€ that will force me.
What kinds of problems do you have?

Maybe you can post your configuration and docker-compose.yml. Iā€˜d like to try this once I have some free time.

Sure (please note Iā€™m running two different instances of OpenHab, therefore I need to run the second one on different ports):

docker-compose.yaml

services:
  influxdb2:
    image: influxdb:latest
    container_name: influxdb2
    volumes:
      - influxdb2:/var/lib/influxdb2:rw
    ports:
      - 8086:8086
    restart: unless-stopped

  grafana:
    image: grafana/grafana
    container_name: grafana
#    network_mode: host
    volumes:
      - grafana-storage:/var/lib/grafana
    environment:
      - GF_SECURITY_ALLOW_EMBEDDING=true
#      - GF_AUTH_ANONYMOUS_ENABLED=true
#      - GF_AUTH_DISABLE_LOGIN_FORM=TRUE
    ports:
      - 3000:3000
    restart: unless-stopped 
    depends_on:
      - influxdb2

  openhab:
    image: openhab/openhab
    container_name: openhab
    restart: unless-stopped
    network_mode: host
    volumes:
      - /etc/localtime:/etc/localtime:ro
      - /etc/timezone:/etc/timezone:ro
      - openhab_addons:/openhab/addons
      - openhab_conf:/openhab/conf
      - openhab_userdata:/openhab/userdata
    environment:
      - CRYPTO_POLICY=unlimited
    depends_on:
      - influxdb2

  openhab7:
    image: openhab/openhab
    container_name: oh7
    restart: unless-stopped
    network_mode: host
    volumes:
      - /etc/localtime:/etc/localtime:ro
      - /etc/timezone:/etc/timezone:ro
      - oh7_addons:/openhab/addons
      - oh7_conf:/openhab/conf
      - oh7_userdata:/openhab/userdata
    environment:
      - OPENHAB_HTTP_PORT=8082
      - OPENHAB_HTTPS_PORT=8843
    depends_on:
      - influxdb2

volumes:
  influxdb2:
    external: true
  grafana-storage:
    external: true
  openhab_addons:
    external: true
  openhab_conf:
    external: true
  openhab_userdata:
    external: true
  oh7_addons:
    external: true
  oh7_conf:
    external: true
  oh7_userdata:
    external: true

I was also playing (work in progress) with portainer configuration that I beleive worked, but did not yet migrate to it (please note it contains much more stuff, so that it could become the ā€œhome automationā€ hub):

master.yaml

version: '4.0.1'

services:
  openhab:
    image: openhab/openhab:latest
    container_name: openhab
    depends_on:
      - influxdb
      - mosquitto
    restart: always
    privileged: true
    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
    environment:
      TZ: Europe/Prague
      OPENHAB_HTTP_PORT: 8080
      OPENHAB_HTTPS_PORT: 8443
      CRYPTO_POLICY: "unlimited"
      EXTRA_JAVA_OPTS: "-Duser.timezone=Europe/Prague"
      USER_ID: 999
      GROUP_ID: 995
    network_mode: host

  openhab7:
    image: openhab/openhab:latest
    container_name: openhab7
    depends_on:
      - influxdb
      - mosquitto
    restart: always
    privileged: true
    volumes:
      - "/etc/localtime:/etc/localtime:ro"
      - "/etc/timezone:/etc/timezone:ro"
      - data_openhab7_conf:/openhab/conf
      - data_openhab7_addons:/openhab/addons
      - data_openhab7_userdata:/openhab/userdata
    environment:
      TZ: Europe/Prague
      OPENHAB_HTTP_PORT: 8082
      OPENHAB_HTTPS_PORT: 8843
      CRYPTO_POLICY: "unlimited"
      EXTRA_JAVA_OPTS: "-Duser.timezone=Europe/Prague"
      USER_ID: 999
      GROUP_ID: 995
    network_mode: host 


  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/Prague


  influxdb:
    image: influxdb:latest
    container_name: influxdb
    restart: always
    volumes:
      - data_influxdb2:/var/lib/influxdb2
      - data_influxdb2_config:/etc/influxdb2
    ports:
      - 8086:8086      
    environment:
      - TZ=Europe/Prague
      
  grafana:
    image: grafana/grafana
    container_name: grafana
#    network_mode: host
    volumes:
      - data_grafana-storage:/var/lib/grafana
    environment:
      - GF_SECURITY_ALLOW_EMBEDDING=true
#      - GF_AUTH_ANONYMOUS_ENABLED=true
#      - GF_AUTH_DISABLE_LOGIN_FORM=TRUE
    ports:
      - 3000:3000
    restart: unless-stopped 
    depends_on:
      - influxdb

  duplicati:
    image: duplicati/duplicati
    container_name: duplicate
    environment:
      - PUID=0
      - PGID=0
      - TZ=Europe/Prague
    volumes:
      - data_duplicati_backups:/backups
      - data_duplicati_config:/config
      - data_duplicati_data:/data 
      - data_grafana-storage:/source/Grafana
      - data_homeassistant:/source/homeassistant      
      - data_influxdb2:/source/influxdb2
      - data_influxdb2_config:/source/influxdb2_config
      - data_mosquitto_config:/source/mosquitto_config
      - data_mosquitto_data:/source/mosquitto_data
      - data_mosquitto_log:/source/mosquitto_log
      - data_nginx_proxy_manager_data:/source/nginx_proxy_manager_data
      - data_nginx_proxy_manager_letsencrypt:/source/nginx_proxy_manager_letsencrypt
      - data_openhab7_addons:/source/openhab7_addons 
      - data_openhab7_conf:/source/openhab7_conf 
      - data_openhab7_userdata:/source/openhab7_userdata 
      - data_openhab_addons:/source/openhab_addons
      - data_openhab_conf:/source/openhab_conf
      - data_openhab_userdata:/source/openhab_userdata
      - data_plex_config:/source/plex_config
      
    ports:
      - 8200:8200
    restart: unless-stopped

  frontail:
    image: welteki/frontail-openhab:latest
    container_name: frontail
    restart: always
    ports:
      - 9001:9001
    volumes:
      - data_openhab_userdata:/openhab/userdata:ro

  samba:
    image: dperson/samba
    container_name: samba
    restart: always
    ports:
      - "137:137/udp"
      - "138:138/udp"
      - "139:139/tcp"
      - "445:445/tcp"
    healthcheck:  
      disable: true  
    environment:
    - TZ=Europe/Prague
    - WORKGROUP=workgroup  
    - PERMISSIONS=true
    - RECYCLE=false
    - USER=user1;xxxxxx
    - USERID=1000
    - GROUPID=1000   
    - SHARE1=docker;/shares/docker;yes;no;no;
    - SHARE2=ext;/shares/ext;yes;no;yes;
    - SHARE3=log;/shares/log;yes;no;yes;    
    - SHARE10=duplicati_backups;/shares/data_duplicati_backups;yes;no;no;
    - SHARE11=duplicati_config;/shares/duplicati_config;yes;no;no;
    - SHARE12=duplicati_data;/shares/data_duplicati_data;yes;no;no;
    - SHARE20=data_grafana-storage;/shares/data_grafana-storage;yes;no;no;
    - SHARE21=data_homeassistant;/shares/data_homeassistant;yes;no;no;    
    - SHARE22=data_homer_assets;/shares/data_homer_assets;yes;no;no;   
    - SHARE30=influxdb2;/shares/influxdb2;yes;no;no;
    - SHARE31=influxdb2_config;/shares/influxdb2_config;yes;no;no;
    - SHARE32=data_influxdb2_config;/shares/influxdb2_config;yes;no;no;
    - SHARE40=mosquitto_config;/shares/mosquitto_config;yes;no;no;
    - SHARE41=mosquitto_log;/shares/mosquitto_log;yes;no;no;
    - SHARE50=data_nginx_proxy_manager_data;/shares/data_nginx_proxy_manager_data;yes;no;no;
    - SHARE51=data_nginx_proxy_manager_letsencrypt;/shares/data_nginx_proxy_manager_letsencrypt;yes;no;no;
    - SHARE60=openhab7_addons;/shares/openhab7_addons;yes;no;no;
    - SHARE61=openhab7_conf;/shares/openhab7_conf;yes;no;no;
    - SHARE62=openhab7_userdata;/shares/openhab7_userdata;yes;no;no;
    - SHARE63=openhab_addons;/shares/openhab_addons;yes;no;no;
    - SHARE64=openhab_conf;/shares/openhab_conf;yes;no;no;
    - SHARE65=openhab_userdata;/shares/openhab_userdata;yes;no;no;
    - SHARE66=data_plex_config;/shares/data_plex_config;yes;no;no;
    volumes:
      - /var/lib/samba:/var/lib/samba
      - /run/samba:/run/samba
      - /etc:/etc
      - /var/log/samba:/var/log/samba
      - /var/cache/samba:/var/cache/samba
      - /docker:/shares/docker
      - /mnt/ext:/shares/ext
      - /var/log:/shares/log
      - data_duplicati_backups:/shares/duplicati_backups
      - data_duplicati_config:/shares/duplicati_config
      - data_duplicati_data:/shares/duplicati_data
      - data_grafana-storage:/shares/data_grafana-storage
      - data_homeassistant:/shares/data_homeassistant
      - data_homer_assets:/shares/data_homer_assets
      - data_influxdb2:/shares/influxdb2
      - data_influxdb2_config:/shares/influxdb2_config
      - data_mosquitto_config:/shares/mosquitto_config
      - data_mosquitto_log:/shares/mosquitto_log
      - data_nginx_proxy_manager_data:/shares/data_nginx_proxy_manager_data
      - data_nginx_proxy_manager_letsencrypt:/shares/data_nginx_proxy_manager_letsencrypt
      - data_openhab7_addons:/shares/openhab7_addons
      - data_openhab7_conf:/shares/openhab7_conf
      - data_openhab7_userdata:/shares/openhab7_userdata      
      - data_openhab_addons:/shares/openhab_addons
      - data_openhab_conf:/shares/openhab_conf
      - data_openhab_userdata:/shares/openhab_userdata
      - data_plex_config:/shares/data_plex_config

  plex:
    image: linuxserver/plex
    container_name: plex
    network_mode: host
    environment:
      - PUID=1000 
      - PGID=1000 
      - VERSION=docker
#    ports:
#      - '32400:32400'
    volumes:
      - data_plex_config:/config
      - /mnt/ext/plex_content:/content
    restart: always

  nginx-proxy-manager:
    image: 'jc21/nginx-proxy-manager:latest'
    container_name: nginx-proxy-manager
    restart: unless-stopped
    ports:
      # These ports are in format <host-port>:<container-port>
      - '80:80' # Public HTTP Port
      - '443:443' # Public HTTPS Port
      - '81:81' # Admin Web Port
      # Add any other Stream port you want to expose
      # - '21:21' # FTP

    # Uncomment the next line if you uncomment anything in the section
    # environment:
      # Uncomment this if you want to change the location of
      # the SQLite DB file within the container
      # DB_SQLITE_FILE: "/data/database.sqlite"

      # Uncomment this if IPv6 is not enabled on your host
      # DISABLE_IPV6: 'true'
    volumes:
      - data_nginx_proxy_manager_data:/data
      - data_nginx_proxy_manager_letsencrypt:/etc/letsencrypt

  homeassistant:
    image: lscr.io/linuxserver/homeassistant
    container_name: homeassistant
    network_mode: host
    environment:
      - PUID=1000
      - PGID=1000
      - TZ=Europe/Prague
    volumes:
      - data_homeassistant:/config
    restart: unless-stopped      
    
  # homer:
    # image: b4bz/homer:latest
    # container_name: homer
    # restart: always
    # volumes:
      # - data_homer_assets:/www/assets
    # ports:
      # - 8080:8080
      
  rpi-monitor:
    image: michaelmiklis/rpi-monitor:latest
    container_name: rpi-monitor
    volumes:
      - /opt/vc:/opt/vc
      - /boot:/boot
      - /sys:/dockerhost/sys:ro
      - /etc:/dockerhost/etc:ro
      - /proc:/dockerhost/proc:ro
      - /usr/lib:/dockerhost/usr/lib:ro
    devices:
      - "/dev/vchiq:/dev/vchiq" 
      - "/dev/vcsm-cma:/dev/vcsm-cma"  
    restart: unless-stopped
    ports:
      - 8888:8888      
  
  glances:
    image: nicolargo/glances:latest
    container_name: glances
    restart: always
    ports:
      - 61208:61208
      - 61209:61209
    volumes:
      - /var/run/docker.sock:/var/run/docker.sock:ro
    environment:
      - TZ=Europe/Prague
      - "GLANCES_OPT=-w"
#     network_mode: host
    pid: host


volumes:
  data_openhab_conf:
  data_openhab_addons:
  data_openhab_userdata:
  data_openhab7_conf:
  data_openhab7_addons:
  data_openhab7_userdata:  
  data_mosquitto_config:
  data_mosquitto_data:
  data_mosquitto_log:
  data_influxdb2:
  data_influxdb2_config:
  data_duplicati_data:
  data_duplicati_config:
  data_duplicati_backups:
  data_grafana-storage:
  data_plex_config:
  data_nginx_proxy_manager_data:
  data_nginx_proxy_manager_letsencrypt:
  data_homeassistant:
  data_homer_assets:

Update: I fixed a bug in the configuration above that prevented write access to samba shares.

Itā€™s a Iong time, but I kind of remember I was changing some permissions and switching to ā€œmanual userā€ and running smb as root to achieve it (as also different directories had different owners), but I guess it was more brute force and possibly insecureā€¦ What exactly was your fix? Thanks!

I removed the user-configuration and included ā€œall;all;allā€ behind all sharesā€¦
image
ā€¦ and included the read_only: false and stdin_open:true. Now it seems to be working (fingerā€™s crossed). Also updated in the docker-compose.yml in the very first post of this thread.

Hi,

I configured all the files for persistence (openhab_conf/persistence/influxdb.persist, openhab_conf/service/influxdb.cfg) and in InfluxDB2 I created a user ā€œopenhabā€ to which I assigned an organization ā€œorgā€ which has a database " openhab_db" . But I donā€™t know why persistence still doesnā€™t work. I donā€™t know if Iā€™m missing something.

Thanks

Log entries would help.

For InfluxDB2 you have to use a token.

My $OPENHAB_CONF/services/influxdb.cfg:

# The database URL, e.g. http://127.0.0.1:8086 or https://127.0.0.1:8084 .
# Defaults to: http://127.0.0.1:8086
# url=http(s)://<host>:<port>
url=http://192.168.178.99:8086

# The name of the database user, e.g. openhab.
# Defaults to: openhab
# user=<user>
user=openhab

# The password of the database user.
# password=

# The name of the database, e.g. openhab.
# Defaults to: openhab
# db=<database>
db=openhab

# The version of InfluxDB, V1 or V2
version=V2

# The token for version2 connections
token=1234567890abcdefghijklmnopqrstuvxyz1234567890abcdefghijklmnopqrstuvxyzABCDEFGHIJKLMNOP==

# The name of the retention Policy, e.g. openhab.
retentionPolicy=openHAB

for obvious reasons, thatā€™s not my real token, but you get the point. you can create the token via InfluxDB Web UI. Please pay attention to the fact, that there is no password set. You donā€™t need no password when using the token.

db here is the name of the organisation(!) and retentionPolicy is the name of the Bucket (!)