Samba docker container
Go to file
2016-11-06 20:03:17 -08:00
.dockerignore .dockerignore add logo; derp add logo to git 2015-08-15 19:02:06 -04:00
Dockerfile Dockerfile derp remove psutils add procps 2016-10-21 07:36:47 -04:00
Dockerfile.aarch64 Dockerfile update to stretch 2016-10-18 09:28:57 -04:00
LICENSE trim whitespace 2016-02-01 23:55:16 -05:00
logo.jpg .dockerignore add logo; derp add logo to git 2015-08-15 19:02:06 -04:00
README.md Add documentation 2016-10-31 21:45:07 -07:00
samba.sh Forgot getopts option 2016-11-06 20:03:17 -08:00

logo

Samba

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

Configuration

sudo docker run -it --rm dperson/samba -h
Usage: samba.sh [-opt] [command]
Options (fields in '[]' are optional, '<>' are required):
    -h          This help
    -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
    -s "<name;/path>[;browsable;readonly;guest;users;admins]" Configure a share
                required arg: "<name>;<comment>;</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
    -m          Enable homedir sharing for users (defined below).  Mount your
                users' homedirs at /home
    -t ""       Configure timezone
                possible arg: "[timezone]" - zoneinfo timezone for container
    -u "<username;password>"       Add a user
                required arg: "<username>;<passwd>"
                <username> for user
                <password> for user
                [ID] for user
    -w "<workgroup>"       Configure the workgroup (domain) samba should use
                required arg: "<workgroup>"
                <workgroup> for samba

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

ENVIRONMENT VARIABLES (only available with docker run)

  • NMBD - As above, enable nmbd
  • TZ - As above, set a zoneinfo timezone, IE EST5EDT
  • WORKGROUP - As above, set workgroup

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.

Examples

Any of the commands can be run at creation with docker run or later with docker exec -it samba.sh (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 samba.sh -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"

Sharing home directories

Ensure that /home in the container is mounted to some place where you want your homedirs to live, or the actual homedirs on the local host.

You will also need to add the UIDs of each user, matching those in /home/.

sudo docker run -it -p 139:139 -p 445:445 -v /home:/home -d dperson/samba \
            -u "example1;badpass;1000" \
            -u "example2;badpass;1050" \
            -m

User Feedback

Issues

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