Samba shares for multiple users

Hello all,

not long ago I moved my complete smart home setup to docker compose. Everything is running fine except the samba shares i need to setup to be able to work properly with my config files.

The Problem: the openhab container has a sperarate user called “openhab”. Im not able to set up both of these paths with samba service:
/home/pi with user “pi”
/home/openhab with user “openhab”

I just can one of them working, the other is accessable but not writeable. The openhab user is normally nologin, so I deleted it once and recreated it as normal user.

Now im out of ideas, i tried a lot. Any hints please?

version: "3"
volumes:
    prometheus_data: {}
    #grafana_data: {}
    openhab_data_openhab_conf:
        external: true
        name: openhab_data_openhab_conf
    openhab_data_openhab_userdata:
        external: true
        name: openhab_data_openhab_userdata
    openhab_data_openhab_addons:
        external: true
        name: openhab_data_openhab_addons    
    openhab_docker:
        external: true
        name: openhab_docker

networks:
  loki:

#################### openhab & services 
services:
  openhab:
    image: "openhab/openhab:3.3.0"
    container_name: openhab
    restart: always
    network_mode: host
    volumes:
      - /etc/localtime:/etc/localtime:ro
      - /etc/timezone:/etc/timezone:ro
      - /home/openhab/openhab_addons:/openhab/addons
      - /home/openhab/openhab_conf:/openhab/conf
      - /home/openhab/openhab_userdata:/openhab/userdata
      #- "./openhab/openhab_userdata/logs:/var/log"
      #- ./openhab:/etc/openhab/misc
    environment:
      CRYPTO_POLICY: "unlimited"
      EXTRA_JAVA_OPTS: "-Duser.timezone=Europe/Berlin"
      OPENHAB_HTTP_PORT: "8080"
      OPENHAB_HTTPS_PORT: "8443"
      USER_ID: 999
      GROUP_ID: 994
  frontail:
    container_name: frontail
    restart: unless-stopped
    image: mthenw/frontail
    command: --disable-usage-stats --ui-highlight --ui-highlight-preset /frontail/preset/openhab.json -t openhab -l 2000 -n 200 /logs/openhab.log /logs/events.log
    depends_on:
      - openhab
    volumes:
      - ./frontail/preset.json:/frontail/preset/openhab.json:ro
      - ./frontail/openhab.css:/frontail/web/assets/styles/openhab.css:ro
      - /home/openhab/openhab_userdata/logs:/logs:ro
    ports:
      - "8001:9001"
    networks:
      - loki
  mosquitto:
    image: eclipse-mosquitto:2
    container_name: mosquitto
    restart: always
    volumes:
      - ./mosquitto/config/:/mosquitto/config/
#:ro
      - /var/log/mosquitto/:/mosquitto/log/
      - ./mosquitto/data:/mosquitto/data/
    ports:
      - 1883:1883
      - 9001:9001
    networks:
      - loki
  zigbee2mqtt:
    container_name: zigbee2mqtt
    container_name: zigbee2mqtt
    image: koenkk/zigbee2mqtt:1.28.2
    depends_on: 
      - "mosquitto"
    restart: always
    volumes:
      - ./zigbee2mqtt/data:/app/data
      - /run/udev:/run/udev:ro
      - /var/log/zigbee2mqtt:/app/data/log
#    ports:
      # Frontend port
#      - 8085:8080
    environment:
      - TZ=Europe/Berlin
    devices:
      # Make sure this matched your adapter location
      - /dev/serial/by-id/usb-Silicon_Labs_slae.sh_cc2652rb_stick_-_slaesh_s_iot_stuff_00_12_4B_00_21_CC_4B_B3-if00-port0:/dev/ttyACM0
    network_mode: host

  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/Berlin'
#      - USERID=1000
#      - GROUPID=1000
#      - PUID=999
#      - PGID=994
      - WORKGROUP=workgroup
#      - PERMISSIONS=true
      - RECYCLE=false
      - USER1=pi;mypasswd;
      - USER2=openhab;mypasswd;
      - SHARE1=openhab_docker;/shares/openhab_docker;yes;no;yes;openhab;
      - SHARE2=openhab_userdata;/shares/openhab_userdata;yes;no;yes;openhab;
      - SHARE3=openhab_conf;/shares/openhab_conf;yes;no;yes;
#      - SHARE3=openhab_addons;/shares/openhab_addons;yes;yes;yes;
#      - SHARE4=docker;/shares/docker;yes;no;yes;
#      - SHARE5=log;/shares/log;yes;no;yes;
    volumes:
      - /home/openhab/openhab_conf:/shares/openhab_conf
      - /home/openhab/openhab_userdata:/shares/openhab_userdata
      - /home/openhab/openhab_addons:/shares/openhab_addons
      - /home/pi:/shares/openhab_docker
    networks:
      - loki


#################### grafana & services
  loki:
    image: grafana/loki:latest
    container_name: loki
    volumes:
      - /home/pi/loki:/etc/loki
    ports:
      - "3100:3100"
    restart: always
    command: -config.file=/etc/loki/loki-config.yml
    networks:
      - loki
  promtail:
    image: grafana/promtail:latest
    container_name: promtail
    volumes:
      - /var/log:/var/log
      - /home/pi/promtail:/etc/promtail
      - /home/openhab/openhab_userdata/logs:/var/log/openhab   
 # ports:
    #   - "1514:1514" # this is only needed if you are going to send syslogs
    restart: unless-stopped
    command: -config.file=/etc/promtail/promtail-config.yml
    networks:
      - loki
  grafana:
    image: grafana/grafana:latest
    container_name: grafana
    user: "1000"
    volumes:
    - /home/pi/grafana:/var/lib/grafana
    ports:
      - "3000:3000"
    restart: always
    networks:
      - loki
  prometheus:
    image: prom/prometheus:latest
    container_name: prometheus
    volumes:
      - /home/pi/prometheus/:/etc/prometheus/
      - prometheus_data:/prometheus
    command:
      - '--config.file=/etc/prometheus/prometheus.yml'
      - '--storage.tsdb.path=/prometheus'
      - '--web.console.libraries=/usr/share/prometheus/console_libraries'
      - '--web.console.templates=/usr/share/prometheus/consoles'
    ports:
      - 9090:9090
    networks:
      - loki
    restart: always
  node-exporter:
    image: quay.io/prometheus/node-exporter:latest
    container_name: node_exporter
    volumes:
      - /proc:/host/proc:ro
      - /sys:/host/sys:ro
      - /:/rootfs:ro
      - /:/host:ro,rslave
    command: 
      - '--path.rootfs=/host'
      - '--path.procfs=/host/proc' 
      - '--path.sysfs=/host/sys'
      - --collector.filesystem.ignored-mount-points
      - "^/(sys|proc|dev|host|etc|rootfs/var/lib/docker/containers|rootfs/var/lib/docker/overlay2|rootfs/run/docker/netns|rootfs/var/lib/docker/aufs)($$|/)"
    ports:
      - 9100:9100
    networks: 
      - loki
    restart: always
    deploy:
      mode: global
  influxdb:
    image: influxdb:latest
    container_name: influxdb
    networks:
      - loki
    ports:
      - 8086:8086
    volumes:
      - ./influxdb/config:/etc/influxdb2
      - ./influxdb/data:/var/lib/influxdb2
    environment:
      - INFLUXDB_DB=openhab_data
    restart: always  
###################### portainer
  portainer:
    image: portainer/portainer-ce:latest
    container_name: portainer
    restart: unless-stopped
    security_opt:
      - no-new-privileges:true
    volumes:
      - /etc/localtime:/etc/localtime:ro
      - /var/run/docker.sock:/var/run/docker.sock:ro
      - ./portainer:/data
    ports:
      - 9000:9000

UPDATE: im a little step further. i now realized that as soon as I mount the first folder, I cant mount the other folder with separate user because windows gives an error that it is not allowed to connect same server with separate users.

Is it really impossible to map both of my folders? My plan was to get the folders into VS Code and then use github for versioning.

It looks like it is Windows related then, but based on the posts on SuperUser

you could add multiple hostnames to the same samba server in the hosts file ( C\Windows\System32\Drivers\etc\hosts ) and use different hostnames fo different users to make Windows “believe” it connects to different servers.

Without this post I would have suggested adding multiple IP addresses to the samba server (the server that runs the samba container).

1 Like

That’s it!

I even just added one share with host name and one with ip address and it also worked.

Thank you!