Sign inSign up

bfren/samba

By bfren

โ€ขUpdated 7 minutes ago

Image
0

10K+

bfren/samba repository overview

โ Samba

GitHub release (latest by date) Docker Pulls Docker Image Size GitHub Workflow Status

Docker Hubโ  - Quay.ioโ  - bfren ecosystemโ 

โ Introduction

Sambaโ  file server, sharing folders with Windows, macOS and Linux over SMB. Users and shares are defined in one JSON file, so there's no smb.conf to write.

It is built on Alpine + S6โ , with Samba from Alpine's packages.

โ Quickstart

docker-compose.yml:

services:
  samba:
    image: quay.io/bfren/samba:3.2
    restart: unless-stopped
    ports:
      - "0.0.0.0:445:445"
    environment:
      - BF_SAMBA_UID=1000
    volumes:
      - ./v/shares.json:/files/shares.json:ro
      - ./v/docs:/files/docs
      - ./v/public:/files/public

v/shares.json:

{
    "$schema": "https://schemas.bfren.dev/docker/samba/shares.json",
    "users": [
        { "name": "fred", "pass": "change-me" }
    ],
    "shares": [
        { "name": "docs", "comment": "Documents", "users": [ "fred" ] },
        { "name": "public", "users": [ "*" ] }
    ]
}

Run docker compose up -d, then connect to \\<server>\docs (Windows) or smb://<server>/docs (macOS / Linux) as fred. See shares-conf-sample.json for more.

โ Features

  • ๐Ÿ“ Users and shares defined in one JSON file, with a schema for validation and autocomplete
  • ๐Ÿ‘ฅ Each share limited to its users, or open to guests
  • ๐Ÿ‘ค Everything is written as one user, so files on the host have the owner you choose
  • ๐Ÿ”’ SMB over TCP port 445 only
  • ๐Ÿฉบ Health check that lists the shares
  • ๐Ÿงช Built-in tests

โ Tags

Images are published to Docker Hub (bfren/samba) and Quay.io (quay.io/bfren/samba) for linux/amd64, linux/arm/v7 and linux/arm64, with Samba 4.23.8 on Alpine 3.24.

TagExampleUse when
latestYou always want the newest image
MAJOR3You want updates, but not breaking changes
MINOR3.2You want fixes only - recommended
VERSION3.2.0You want to pin this image exactly
sambaX, sambaX.Ysamba4.23You want a Samba version
sambaX.Y.Zsamba4.23.8You want an exact Samba release
sambaX.Y-VERSIONsamba4.23-3.2.0You want to pin both

โ Configuration

โ Ports
PortPurpose
445SMB over TCP
โ Volumes
VolumePurpose
/filesshares.json, and a folder for each share - mount each one separately.
โ shares.json

/files/shares.json must exist - the container stops without it.

PropertyDescription
usersA list of users, each with a name and pass.
sharesA list of shares, each shared from /files/<name>.
Share propertyDescriptionDefault
nameRequired. The share's name, and the folder in /files it shares.
commentDescription shown to clients.
usersUsers who can access the share - or [ "*" ] for a public (guest) share.
browseablefalse to hide the share from share lists.true
writeablefalse to make the share read-only.true

Public shares are open to everyone who can reach the server, without a password, and are always browseable and writeable.

โ Environment Variables
VariableValuesDescriptionDefault
BF_SAMBA_UIDnumberUID that files are written as - set it to the owner of the folders on the host.1000
BF_SAMBA_WORKGROUPnameWindows workgroup.WORKGROUP
BF_SAMBA_SERVERtextServer description shown to clients.Samba Server
BF_SAMBA_NETBIOS_ALIASnamesOther names the server answers to.

See Alpine + S6โ  for BF_DEBUG, BF_TZ and the other base image variables.

โ How It Works

On every start:

  1. A samba system user is created with BF_SAMBA_UID (if it doesn't exist yet).
  2. Each user in shares.json that doesn't exist yet is created, with its Samba password.
  3. smb.conf is generated, with a section for each share. Every share uses force user = samba, so whoever connects, files are created and changed as samba.

Then smbd runs under S6, logging to docker logs. The container stops if it crashes. Only smbd runs - there's no NetBIOS name service (nmbd), so the server may not appear when browsing the network: connect to it by name or address.

The health check (every 30 seconds) lists the shares as a guest, using SMB3.

โ Testing

./test.nu   # builds the image and runs /test
./run.sh    # builds the image and opens a shell, using shares-conf-sample.json

/test runs this image's tests alongside the base images' tests: loading shares.json, generating each share (limited, public, browseable and writeable), the generated smb.conf, and the installed Samba version.

โ Troubleshooting

โ The container stops straight after starting

/files/shares.json is missing or isn't valid JSON - check docker logs <container>.

โ I changed a password but the old one still works

Users are only created once, so changes to pass are ignored until the container is recreated (docker compose up -d --force-recreate). Or change it straight away with docker exec -it <container> smbpasswd <name>.

โ Files on the host belong to the wrong user

Set BF_SAMBA_UID to the UID of the user who owns the folders on the host (id -u), then recreate the container.

โ I can't see the server when browsing the network

There is no NetBIOS service - connect directly, e.g. \\192.168.1.10\docs.

โ FAQs

โ Can I use the same share for several users with different permissions?

Not within one share - create a separate share for each set of permissions.

โ Licence

Copyright (c) 2022-2026 bfrenโ  (unless otherwise stated)

Tag summary

Content type

Image

Digest

sha256:260719dc0โ€ฆ

Size

48.6 MB

Last updated

7 minutes ago

docker pull bfren/samba