Spinning Up a Samba Server for Testing with Docker

Testing Samba Server on Docker

* This page contains promotional content

At work there was a request to build a temporary Windows file sharing server on Linux and test against it.
Since it was only temporary, I wanted to avoid dirtying the system by installing directly onto it, so I built it with Docker.

That said, a Docker image already exists, so all I do is use it

This repository looks comparatively recently updated and maintained

git clone

$ git clone https://github.com/ServerContainers/samba.git
$ cd samba

Since it is for testing, I build an environment that can just read and write, without user restrictions and the like

docker-compose.yml

Edit the SAMBA_VOLUME_CONFIG_public entry in docker-compose.yml

version: '3'

services:
  samba:
    build: .
    image: ghcr.io/servercontainers/samba
    restart: always
    network_mode: host
    # uncomment to solve bug: https://github.com/ServerContainers/samba/issues/50 - wsdd2 only - not needed for samba
    cap_add:
      - CAP_NET_ADMIN
    environment:
      MODEL: 'TimeCapsule'
      AVAHI_NAME: SambaTest
      SAMBA_CONF_LOG_LEVEL: 3
      # uncomment to disable optional services
      #WSDD2_DISABLE: 1
      #AVAHI_DISABLE: 1
      GROUP_family: 1500

      SAMBA_VOLUME_CONFIG_public: "[Public]; path=/shares/public; writable =yes; guest ok = yes; guest only = yes;read only = no; browseable = yes;"
      - ./shares/public:/shares/public
sudo docker-compose up -d

Checking it

With this, I confirmed that I can read and write inside /shares/public/ over Windows networking or a Samba connection