Skip to content

Dynamic volume support - #181

Open
fawzibr wants to merge 9 commits into
ServerContainers:masterfrom
fawzibr:master
Open

fawzibr wants to merge 9 commits into
ServerContainers:masterfrom
fawzibr:master

Conversation

@fawzibr

@fawzibr fawzibr commented Oct 9, 2026 •

Copy link
Copy Markdown

I was interested sharing USB drives connected to the machine automatically without having to stop/start the container. I created an issue for it.

After working on it I think its ready.

The compose file I'm using:

services:
  samba:
    container_name: samba
    image: ghcr.io/fawzibr/samba
    restart: always
    network_mode: host
    cap_add:
      - CAP_NET_ADMIN
    environment:
      SAMBA_CONF_WORKGROUP: <workgroup>
      SAMBA_CONF_SERVER_STRING: Samba Server (Docker)
      SAMBA_CONF_SERVER_ROLE: standalone server
      SAMBA_CONF_MAP_TO_GUEST: Bad User
      SAMBA_CONF_LOG_LEVEL: 1
      SAMBA_GLOBAL_CONFIG_wins_SPACE_support: 'yes'
      SAMBA_GLOBAL_CONFIG_follow_SPACE_symlinks: 'yes'
      SAMBA_DYNAMIC_VOLUMES: "yes"
      SAMBA_DYNAMIC_INTERVAL: 1
      SAMBA_DYNAMIC_WEBHOOK_PORT: 9000
    volumes:
      - /etc/avahi/services/:/external/avahi
      - ./dynamic-shares:/dynamic-volumes # directory monitored for changes
      - /media:/media  # directory where USB drives are mounted

New environment variables:

  • SAMBA_DYNAMIC_VOLUMES: Enable dynamic volumes. Default: disabled. Values: enabled/yes/true
  • SAMBA_DYNAMIC_INTERVAL: Monitoring interval in minutes. Default: 1 (0 to disable monitoring)
  • SAMBA_DYNAMIC_WEBHOOK_PORT: Port to manually refresh dynamic volumes. If monitoring is disabled this is the only way to refresh volumes. Address is http://server/hooks/refresh

Creating directories in ./dynamic-shares are automatically mounted. You can create a file named directory.template in ./dynamic-shares with the following:

[global]
browsable = yes
guest ok = yes
create mask = 0777
directory mask = 0777

The keys will be added when mounting the directory. If you want to add specific keys to a directory just create a section with the same name as the directory (Keys in [global] will be added first).

Creating a file with extension '.share' will add the shares in the file. For example, USB.share:

[MY_USB_DRIVE]
path=/media/MY_USB_DRIVE
browsable = yes
guest ok = yes
create mask = 0777
directory mask = 0777

[MY_USB_DRIVE_2]
path=/media/MY_USB_DRIVE_2
browsable = yes
guest ok = yes
create mask = 0777
directory mask = 0777

@MarvAmBass

Copy link
Copy Markdown
Member

Hi, thanks for the work, I won't merge it, as it's somewhat special right - but I'd keep this pull request open in case another user has this need.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants