Public | Automated Build

Last pushed: 17 hours ago
Short Description
Short description is empty for this repo.
Full Description


Samba docker container

What is Samba?

Since 1992, Samba has provided secure, stable and fast file and print services
for all clients using the SMB/CIFS protocol, such as all versions of DOS and
Windows, OS/2, Linux and many others.

How to use this image

By default there are no shares configured, additional ones can be added.

Hosting a Samba instance

sudo docker run -it -p 139:139 -p 445:445 -d dperson/samba

OR set local storage:

sudo docker run -it --name samba -p 139:139 -p 445:445 \
            -v /path/to/directory:/mount \
            -d dperson/samba


sudo docker run -it --rm dperson/samba -h
Usage: [-opt] [command]
Options (fields in '[]' are optional, '<>' are required):
    -h          This help
    -c "<from:to>" setup character mapping for file/directory names
                required arg: "<from:to>" character mappings separated by ','
    -g "<parameter>" Provide global option for smb.conf
                required arg: "<parameter>" - IE: -g "log level = 2"
    -i "<path>" Import smbpassword
                required arg: "<path>" - full file path in container
    -n          Start the 'nmbd' daemon to advertise the shares
    -p          Set ownership and permissions on the shares
    -r          Disable recycle bin for shares
    -S          Disable SMB2 minimum version
    -s "<name;/path>[;browse;readonly;guest;users;admins;wl]" Config a share
                required arg: "<name>;</path>"
                <name> is how it's called for clients
                <path> path to share
                NOTE: for the default values, just leave blank
                [browsable] default:'yes' or 'no'
                [readonly] default:'yes' or 'no'
                [guest] allowed default:'yes' or 'no'
                [users] allowed default:'all' or list of allowed users
                [admins] allowed default:'none' or list of admin users
                [writelist] list of users that can write to a RO share
    -t ""       Configure timezone
                possible arg: "[timezone]" - zoneinfo timezone for container
    -u "<username;password>[;ID;group]"       Add a user
                required arg: "<username>;<passwd>"
                <username> for user
                <password> for user
                [ID] for user
                [group] for user
    -w "<workgroup>"       Configure the workgroup (domain) samba should use
                required arg: "<workgroup>"
                <workgroup> for samba
    -W          Allow access wide symbolic links

The 'command' (if provided and valid) will be run instead of samba

ENVIRONMENT VARIABLES (only available with docker run)

  • CHARMAP - As above, configure character mapping
  • NMBD - As above, enable nmbd
  • SMB - As above, disable SMB2 minimum version
  • TZ - As above, set a zoneinfo timezone, IE EST5EDT
  • WIDELINKS - As above, allow access wide symbolic links
  • WORKGROUP - As above, set workgroup
  • USERID - Set the UID for the samba server
  • GROUPID - Set the GID for the samba server

NOTE: if you enable nmbd (via -n or the NMBD environment variable), you
will also want to expose port 137 and 138 with -p 137:137/udp -p 138:138/udp.


Any of the commands can be run at creation with docker run or later with
docker exec -it (as of version 1.3 of docker).

Setting the Timezone

sudo docker run -it -p 139:139 -p 445:445 -d dperson/samba -t EST5EDT

OR using environment variables

sudo docker run -it -e TZ=EST5EDT -p 139:139 -p 445:445 -d dperson/samba

Will get you the same settings as

sudo docker run -it --name samba -p 139:139 -p 445:445 -d dperson/samba
sudo docker exec -it samba -t EST5EDT ls -AlF /etc/localtime
sudo docker restart samba

Start an instance creating users and shares:

sudo docker run -it -p 139:139 -p 445:445 -d dperson/samba \
            -u "example1;badpass" \
            -u "example2;badpass" \
            -s "public;/share" \
            -s "users;/srv;no;no;no;example1,example2" \
            -s "example1 private;/example1;no;no;no;example1" \
            -s "example2 private;/example2;no;no;no;example2"

User Feedback


If you have any problems with or questions about this image, please contact me
through a GitHub issue.

Docker Pull Command
Source Repository

Comments (9)
21 days ago

Very nice image, thanks!

I'm using it to access the code in another container so I can edit my application live in Sublime Text:
docker run -it -p 139:139 -p 445:445 \
--name code --rm \
-v /app/code:/code \
-e "USERID=0" \
-e "GROUPID=0" \
-d dperson/samba \
-s "code;/code;;no"

5 months ago

Very nice job, thanks!
Inside, line#182, shouldn't it be
[[ "${GROUPID:-""}" =~ ^[0-9]+$ ]] && groupmod -g $GROUPID -o smbuser ?
So the smbuser group id can be overwritten, instead of group users.

5 months ago

Somethings gone wrong, the container is throwing an error now...

Error loading module '/usr/lib/x86_64-linux-gnu/samba/vfs/': /usr/lib/x86_64-linux-gnu/samba/vfs/ cannot open shared object file: No such file or directory
error probing vfs module 'recycle': NT_STATUS_UNSUCCESSFUL
smbd_vfs_init: vfs_init_custom failed for recycle
vfs_init failed for service IPC$

6 months ago

Samba filesize limit 2GB, old version work well.

a year ago

for the -u argument. where does [ID] go? is it -u "<username;password>[;ID]" ? Is this the linux User UID?

Also, how will -p affect file permissions? does it have any arguments like what kind of permissions, what user/group, etc?

If anyone knows, it would help a lot thanks.

a year ago

Thanks for the image!

Watch out that using the -p flag mested up my unix permissions. So use it with caution.

a year ago

NMBD seems not work.
I use docker run -p 139:139 -p 445:445 -p 137:137 -v /a:/a -d --name samba dperson/samba -u "x;x" -s "a;/a;yes;no;yes -n to create container.
But I can't find it nether in "shared" on mac os x nor in "My Network Places" on windows

2 years ago

Great image! Could you extend the with removing of shares or users?

2 years ago

Cool. This is the best samba image have seen so-far.