Page tree

Welcome to FreeSoftwareServers Confluence Wiki

Skip to end of metadata
Go to start of metadata

I chose to use this method → as it uses the standard smb.conf which I already had and I prefer to use this method regardless. My main reason is documentation online will be in relating to editing SMB.CONF and I don't want to have to pass everytrhing through weird "envirvonment" variables and have to figure it all out again. It was as easy as coping my existing data over and firing up this container. This was the first container I deployed which doesn't have an "image" tag, but it's still fairly simple, it just comes with a "DOCKERFILE" which builds the image. 

You can view the file here → and see how simple it is.

Update: Due to the extra volumes and my realize how simple it is, I have created my own DockerFile based on his and now use that.


  • I don't expose /etc/shadow|passwd since I only use IP range permissions w/o PWD (home network)
  • All my shares are served under /mnt so I simply exposed that to the docker-container and voila, it all worked
  • Even after doing systemctl disable/stop samba I still had services (nmdb) using port 138. I had to use "netstat tulpn | grep 138" and kill them manually. Once this container was running I purged samba, enabled docker-container service at boot and reboot. Everything works as expected (smile)
  • There are a bunch of volumes created by this image that were not in the documentation which I mapped below as I prefer to use bind mounts in the same directory for persistence. (And my OCD, I have no "volumes" managed by docker, just bind mounts)


mkdir -p $WD/{mnt,setup,smb_conf}
cd $WD/setup
cat << 'EOF' >Dockerfile
FROM alpine

RUN apk add --update \
    samba-common-tools \
    samba-client \
    samba-server \
    && rm -rf /var/cache/apk/*

ENTRYPOINT ["smbd", "--foreground", "--log-stdout", "--no-process-group"]
CMD []
cat << 'EOF' >docker-compose.yaml
version: '3.7'

    container_name: smbd
    hostname: smbd
    build: .
    container_name: samba
      - "137:137/udp"
      - "138:138/udp"
      - "139:139/tcp"
      - "445:445/tcp"
      - type: bind
        read_only: true
        source: /opt/smbd/smb_conf/
        target: /etc/samba
      - type: bind
        source: /mnt
        target: /mnt
      - 'TZ=America/Whitehorse'
chmod +x docker-compose.yaml


cat << EOF >$WD/
cat << EOL >/lib/systemd/system/smbd.service


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

systemctl enable smbd
systemctl restart smbd
systemctl status smbd
chmod +x $WD/
  • No labels