34
SMB + Docker (lemmy.world)

Is there a way to setup an SMB share or similar via docker? I want to be able to easily turn it off and bind it to a specific folder, and I am comfortable with docker.

Thanks!

top 12 comments
sorted by: hot top controversial new old
[-] mbirth@lemmy.ml 16 points 1 day ago
# https://github.com/ServerContainers/samba

services:
  server:
    image: ghcr.io/servercontainers/samba:latest
    restart: unless-stopped
    network_mode: host
    environment:
      TZ: Europe/London
      MODEL: MacSamba
      SAMBA_GLOBAL_STANZA: "vfs objects = acl_xattr catia fruit streams_xattr; fruit:nfs_aces = no; inherit permissions = yes; fruit:model = MacSamba; fruit:posix_rename = yes; fruit:veto_appledouble = no; fruit:wipe_intentionally_left_blank_rfork = yes; fruit:delete_empty_adfiles = yes; fruit:metadata = stream"
      SAMBA_GLOBAL_CONFIG_load_SPACE_printers: no
      SAMBA_GLOBAL_CONFIG_printing: bsd
      SAMBA_GLOBAL_CONFIG_printcap_SPACE_name: /dev/null
      SAMBA_GLOBAL_CONFIG_disable_SPACE_spoolss: yes
      SAMBA_GLOBAL_CONFIG_min_SPACE_protocol: SMB2
      SAMBA_GLOBAL_CONFIG_bind_SPACE_interfaces_SPACE_only: yes
      SAMBA_GLOBAL_CONFIG_interfaces: lo eth0
      SAMBA_CONF_SERVER_STRING: Docker Host Samba
      #SAMBA_CONF_LOG_LEVEL: 3
      ACCOUNT_shareuser: mypassword
      UID_shareuser: 1000
      # avahi seems to introduce issues with the share
      # "The operation can't be completed because the original item for "xxx" can't be found."
      AVAHI_DISABLE: true
      WSDD2_DISABLE: true
      #NETBIOS_DISABLE: true
      SAMBA_VOLUME_CONFIG_myshare: "[myshare]; path=/shares/myshare; valid users = shareuser; guest ok = no; read only = no; browseable = yes"
    volumes:
      - /path/to/myshare:/shares/myshare

Just make sure you don’t have any local SMB server running on the host. And if you need multiple different shares, these all need to go into the same container or you need to define different ports if you use multiple containers.

[-] ikidd@lemmy.world 4 points 21 hours ago

Those are quite the environment variable names there.

[-] mbirth@lemmy.ml 4 points 16 hours ago

Yes, it’s explained in the documentation.

E.g.:

SAMBA_GLOBAL_CONFIG_bind_SPACE_interfaces_SPACE_only: yes

maps to:

[global]
bind interfaces only = yes

This way you don’t need to provide any extra configuration file.

[-] ikidd@lemmy.world 3 points 12 hours ago

I'm well aware of how inline environment variables work, but that is one helldammer of a name for one, and I rarely see anyone use actual spaces in .env file variable, let alone translate a space to SPACE in a variable name.

[-] mbirth@lemmy.ml 1 points 9 hours ago* (last edited 9 hours ago)

These variable names are dynamically parsed and used for generating the smb.conf.

And if you need a way to support underscores AND spaces (which are not allowed in a variable name), you have to get creative.

I like the solution as it allows me to encode any possible configuration value (even the most obscure one) in the compose file.

[-] paraphrand@lemmy.world 3 points 1 day ago
[-] tvcvt@lemmy.ml 10 points 1 day ago* (last edited 1 day ago)

That fruit argument is so that samba plays nicely with Apple’s SMB client implementation.

[-] Dust0741@lemmy.world 3 points 1 day ago

Awesome thank you!

[-] dotslashme@infosec.pub 6 points 1 day ago

I use dperson/samba, which is both simple and comes with usage examples.

[-] tuxec@infosec.pub 6 points 1 day ago

The last commit was 5 years ago. There are very high chamces the container image is full of vulnerabilities. You might wanna rebuild it yourself.

[-] dotslashme@infosec.pub 2 points 1 day ago

Excellent point, thank you!

[-] mbirth@lemmy.ml 2 points 1 day ago

There's dockurr/samba which is also pretty easy to setup, but doesn't allow much deviation from the defaults.

this post was submitted on 08 Jan 2025
34 points (97.2% liked)

Selfhosted

40971 readers
527 users here now

A place to share alternatives to popular online services that can be self-hosted without giving up privacy or locking you into a service you don't control.

Rules:

  1. Be civil: we're here to support and learn from one another. Insults won't be tolerated. Flame wars are frowned upon.

  2. No spam posting.

  3. Posts have to be centered around self-hosting. There are other communities for discussing hardware or home computing. If it's not obvious why your post topic revolves around selfhosting, please include details to make it clear.

  4. Don't duplicate the full text of your blog or github here. Just post the link for folks to click.

  5. Submission headline should match the article title (don’t cherry-pick information from the title to fit your agenda).

  6. No trolling.

Resources:

Any issues on the community? Report it using the report flag.

Questions? DM the mods!

founded 2 years ago
MODERATORS