Coder Social home page Coder Social logo

samba-docker's Introduction

Convert an existing Samba server to Docker

This Docker Compose configuration can be used to convert an existing Samba server over to Docker with little effort. Just edit the docker-compose.yml file to add your shares, set the timezone TZ variable if desired, then bring the server up:

docker-compose up -d --build

This assumes you have a working Samba installation, with configuration in /etc/samba and library files in /var/lib/samba. If the paths on the host machine are different, just edit them in the Compose file.

Based on/inspired by dperson/samba, but modified to work with/convert existing (bare metal) installations of Samba.

Blog post

Please see my blog post for the background behind this implementation, the pros and cons compared to the dperson/samba version, and further notes on configuration.

samba-docker's People

Contributors

alubbock avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar

samba-docker's Issues

Slight mod for security

Great article and writeup for move away from dperson/samba. If you want to leverage groups for security be sure to have a small section in volumes for /etc/group:/etc/group:ro. Makes it easier if you have more than 1-3 users and want to really RBAC things in samba. I tested this using your container build and putting the extra volume mount in. Works like a charm.

Feedback on Install - Note Volumes

Hey Alubbock! Thanks for this great work, I prefer to use smb.conf not just because I already had it, but because the internet resources will regard editing smb.conf and I don't want to have to translate that into environment variables!

My main gripe was after I got it running I noticed a bunch of docker-volumes created which I don't like as I strickly use bind mounts. I thought I'd share my notes anyway, I got it running now along with NFS! I'm ready to re-deploy my server and my plan is to not install ANYTHING via apt and be 100% dockerized.

https://www.freesoftwareservers.com/display/FREES/Configure+SAMBA+-+SMB+-+Docker-Compose+-+Using+SMB.CONF

Docker-Compose:

WD=/opt/smbd
mkdir -p $WD/{mnt,setup,smb_conf,smb_data,smb_logs,smb_cache,smb_etc}
cd $WD/setup
curl https://raw.githubusercontent.com/alubbock/samba-docker/master/Dockerfile > Dockerfile
cat << 'EOF' >docker-compose.yaml
version: '3.7'

services:
 smbd:
    container_name: smbd
    hostname: smbd
    build: .
    container_name: samba
    ports:
      - "137:137/udp"
      - "138:138/udp"
      - "139:139/tcp"
      - "445:445/tcp"
    volumes:
      - type: bind
        read_only: true
        source: /opt/smbd/smb_conf/
        target: /etc/samba
      - type: bind
        source: /opt/smbd/smb_data/
        target: /var/lib/samba
      - type: bind
        source: /opt/smbd/smb_logs/
        target: /var/log/samba
      - type: bind
        source: /opt/smbd/smb_etc/
        target: /etc
      - type: bind
        source: /var/run/samba/
        target: /run/samba
      - type: bind
        source: /opt/smbd/smb_cache/
        target: /var/cache/samba
      - type: bind
        source: /mnt
        target: /mnt
    environment:
      - 'TZ=America/Whitehorse'
EOF
chmod +x docker-compose.yaml

SystemD:

WD=/opt/smbd/setup
cat << EOF >$WD/smbd.service.setup.sh
cat << EOL >/lib/systemd/system/smbd.service
[Unit]
Description=smbd_Docker
Requires=docker.service network-online.target

[Service]

Restart=on-abnormal
ExecStart=/usr/bin/docker-compose --project-name smbd --project-directory $WD -f $WD/docker-compose.yaml up
ExecStop=/usr/bin/docker-compose --project-name smbd --project-directory $WD -f $WD/docker-compose.yaml stop

[Install]
WantedBy=multi-user.target
EOL
systemctl enable smbd
systemctl restart smbd
systemctl status smbd
EOF
chmod +x $WD/smbd.service.setup.sh
$WD/smbd.service.setup.sh

Couple of feedback points on time machine post

Not related to this repo, couldn't see a twitter link, so figured this was as good a way as any to reach out.

First, thanks a lot for this. Makes the whole process much easier than the other options I've seen.

https://alexlubbock.com/time-machine-network-backup-linux

I needed a couple of changes to get it working, one was adding ;yes;no to the end of the -s block. This was necessary to get the second "read only" flag set to no, otherwise my share was read only.

I also had to copy the _adisk._tcp service block from here:

https://github.com/dperson/samba/blob/master/_etc_avahi_services_samba.service

Without that I wasn't able to see the share as an option in time machine, even though I could connect to it from my mac.

Container won't start - Samba parameter has changed

Problem: Container won't start and keeps restarting over and over:

docker ps
CONTAINER ID   IMAGE                   COMMAND                  CREATED         STATUS                                  PORTS                              NAMES
6b74dc3ea637   samba-docker_samba      "smbd --foreground -…"   9 seconds ago   Restarting (1) Less than a second ago                                      samba


docker log samba shows:

[...]
2022-08-30T18:27:43.954651577Z  Invalid option --log-stdout: unknown option
2022-08-30T18:27:43.954662469Z
2022-08-30T18:27:43.954671795Z  Usage: smbd [-?bDiFV] [-?|--help] [--usage] [-b|--build-options]
2022-08-30T18:27:43.954681482Z          [-p|--port=STRING] [-P|--profiling-level=PROFILE_LEVEL]
2022-08-30T18:27:43.954690296Z          [-d|--debuglevel=DEBUGLEVEL] [--debug-stdout]
[...]

Samba-Wiki shows that the option "log-stdout" has been changed to "debug-stdout" since version 4.15
(https://wiki.samba.org/index.php/Samba_4.15_Features_added/changed)

So, after changing the following line in the Dockerfile, container starts as expected and everything runs very well :-)
OLD

ENTRYPOINT ["smbd", "--foreground", "--log-stdout", "--no-process-group"]

NEW

ENTRYPOINT ["smbd", "--foreground", "--debug-stdout", "--no-process-group"]

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.