Samba docker by dlandon

From Steak Wiki
Jump to navigationJump to search

This is currently the most popular Samba image for docker. Here are notes for reference.

docker-compose.yml

version: '3'

services:
   samba_fileshare:
      image: dperson/samba
      container_name: samba_share
      ports:
        - 139:139
        - 445:445
#udp is not mandatory
      restart: always
      volumes:
#watch out for semi-colons here between volumes. must be colons NOT semi
        - ./localdir/from/docker-compose/root/:/anydirectory/on/docker/container
      environment:
#however, these are semi-colons in the user section
        USER:    username1;somepassword
        USER2:   username2;somepassword
        USER3:   username3;somepassword
#I put these users on my host machine. disable ssh for them. i didn't bother with uid, gid.
        SHARE:   SambaShareName;/location/on/docker/container;yes;no;no;username1,username2,username3
        SHARE2:   SambaShareName2;/location/on/docker/container2;yes;no;no;username1,username2,username3
#Be careful to avoid doing multiple Share of the same #. It's easy to overlook these.
#e.g. with two SHARE2 items, only the second will be active
        SHARE3:   SambaShareName3;/location/on/docker/container3;yes;no;no;username1,username2,username3
#watch out for folders being owned by root on docker container. Login to container and check share permissions
        TZ: EST5EDT
#Permissions was not required. If you are to use it, you can just put it as below.
#there is no need to pass a value to it.
#        PERMISSIONS:
#for further troubleshooting, download the git repo, and grep through the code.
#note: I had no issues doing samba shares, that were subfolders of a parent share.
#note: no need to specify admins, or users that can write to read only shares.

usage

Test from terminal first. Faster, and more verbose errors.

smbclient -U username1 //ipaddress/sharename

Note that you use forward slashes in the terminal. In file explorer, you will need backslashes.

Back to:

Docker