2015-08-16 01:52:19 +03:00
|
|
|
[![logo](https://raw.githubusercontent.com/dperson/samba/master/logo.jpg)](https://www.samba.org)
|
2015-01-02 07:03:52 +03:00
|
|
|
|
|
|
|
# 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
|
|
|
|
|
2019-08-27 13:49:59 +03:00
|
|
|
sudo docker run -it -p 139:139 -p 445:445 -d dperson/samba -p
|
2015-01-02 07:03:52 +03:00
|
|
|
|
|
|
|
OR set local storage:
|
|
|
|
|
2016-01-29 03:05:20 +03:00
|
|
|
sudo docker run -it --name samba -p 139:139 -p 445:445 \
|
2015-01-02 07:03:52 +03:00
|
|
|
-v /path/to/directory:/mount \
|
2019-08-27 13:49:59 +03:00
|
|
|
-d dperson/samba -p
|
2015-01-02 07:03:52 +03:00
|
|
|
|
|
|
|
## Configuration
|
|
|
|
|
|
|
|
sudo docker run -it --rm dperson/samba -h
|
|
|
|
Usage: samba.sh [-opt] [command]
|
|
|
|
Options (fields in '[]' are optional, '<>' are required):
|
|
|
|
-h This help
|
2016-11-29 21:22:04 +03:00
|
|
|
-c "<from:to>" setup character mapping for file/directory names
|
|
|
|
required arg: "<from:to>" character mappings separated by ','
|
2017-10-08 22:12:08 +03:00
|
|
|
-g "<parameter>" Provide global option for smb.conf
|
|
|
|
required arg: "<parameter>" - IE: -g "log level = 2"
|
2015-06-17 20:37:00 +03:00
|
|
|
-i "<path>" Import smbpassword
|
2016-01-29 03:05:20 +03:00
|
|
|
required arg: "<path>" - full file path in container
|
2016-02-07 02:37:31 +03:00
|
|
|
-n Start the 'nmbd' daemon to advertise the shares
|
2016-06-08 14:36:20 +03:00
|
|
|
-p Set ownership and permissions on the shares
|
2017-05-25 17:48:21 +03:00
|
|
|
-r Disable recycle bin for shares
|
2017-10-08 21:47:27 +03:00
|
|
|
-S Disable SMB2 minimum version
|
2017-12-25 16:02:26 +03:00
|
|
|
-s "<name;/path>[;browse;readonly;guest;users;admins;writelist;comment]"
|
|
|
|
Configure a share
|
2017-06-05 21:38:18 +03:00
|
|
|
required arg: "<name>;</path>"
|
2015-01-02 07:03:52 +03:00
|
|
|
<name> is how it's called for clients
|
|
|
|
<path> path to share
|
2015-08-02 15:23:04 +03:00
|
|
|
NOTE: for the default values, just leave blank
|
2016-01-12 13:15:47 +03:00
|
|
|
[browsable] default:'yes' or 'no'
|
2015-01-02 07:03:52 +03:00
|
|
|
[readonly] default:'yes' or 'no'
|
|
|
|
[guest] allowed default:'yes' or 'no'
|
2019-07-07 09:54:17 +03:00
|
|
|
NOTE: for user lists below, usernames are separated by ','
|
2015-01-02 07:03:52 +03:00
|
|
|
[users] allowed default:'all' or list of allowed users
|
2015-12-17 14:17:34 +03:00
|
|
|
[admins] allowed default:'none' or list of admin users
|
2016-12-12 01:12:11 +03:00
|
|
|
[writelist] list of users that can write to a RO share
|
2017-12-25 16:02:26 +03:00
|
|
|
[comment] description of share
|
2019-07-07 01:34:52 +03:00
|
|
|
-u "<username;password>[;ID;group;GID]" Add a user
|
2015-01-02 07:03:52 +03:00
|
|
|
required arg: "<username>;<passwd>"
|
|
|
|
<username> for user
|
|
|
|
<password> for user
|
2016-08-30 13:01:21 +03:00
|
|
|
[ID] for user
|
2016-12-12 01:12:11 +03:00
|
|
|
[group] for user
|
2019-07-07 01:34:52 +03:00
|
|
|
[GID] for group
|
2016-02-13 02:13:20 +03:00
|
|
|
-w "<workgroup>" Configure the workgroup (domain) samba should use
|
|
|
|
required arg: "<workgroup>"
|
|
|
|
<workgroup> for samba
|
2017-08-17 23:18:01 +03:00
|
|
|
-W Allow access wide symbolic links
|
2018-09-23 19:57:54 +03:00
|
|
|
-I Add an include option at the end of the smb.conf
|
|
|
|
required arg: "<include file path>"
|
|
|
|
<include file path> in the container, e.g. a bind mount
|
2015-01-02 07:03:52 +03:00
|
|
|
|
|
|
|
The 'command' (if provided and valid) will be run instead of samba
|
|
|
|
|
2018-09-23 17:31:44 +03:00
|
|
|
ENVIRONMENT VARIABLES
|
2015-01-02 07:03:52 +03:00
|
|
|
|
2016-11-29 21:22:04 +03:00
|
|
|
* `CHARMAP` - As above, configure character mapping
|
2019-07-06 23:27:43 +03:00
|
|
|
* `GLOBAL` - As above, configure a global option (See NOTE3 below)
|
2017-12-25 16:02:26 +03:00
|
|
|
* `IMPORT` - As above, import a smbpassword file
|
2016-02-07 02:37:31 +03:00
|
|
|
* `NMBD` - As above, enable nmbd
|
2017-12-25 16:02:26 +03:00
|
|
|
* `PERMISSIONS` - As above, set file permissions on all shares
|
|
|
|
* `RECYCLE` - As above, disable recycle bin
|
2019-07-06 23:27:43 +03:00
|
|
|
* `SHARE` - As above, setup a share (See NOTE3 below)
|
2017-10-08 21:47:27 +03:00
|
|
|
* `SMB` - As above, disable SMB2 minimum version
|
2017-10-20 20:43:12 +03:00
|
|
|
* `TZ` - Set a timezone, IE `EST5EDT`
|
2019-07-06 23:27:43 +03:00
|
|
|
* `USER` - As above, setup a user (See NOTE3 below)
|
2017-08-17 23:18:01 +03:00
|
|
|
* `WIDELINKS` - As above, allow access wide symbolic links
|
2016-02-13 02:13:20 +03:00
|
|
|
* `WORKGROUP` - As above, set workgroup
|
2017-01-04 23:54:52 +03:00
|
|
|
* `USERID` - Set the UID for the samba server
|
|
|
|
* `GROUPID` - Set the GID for the samba server
|
2018-09-23 19:57:54 +03:00
|
|
|
* `INCLUDE` - As above, add a smb.conf include
|
2015-01-02 07:03:52 +03:00
|
|
|
|
2016-02-10 22:19:42 +03:00
|
|
|
**NOTE**: if you enable nmbd (via `-n` or the `NMBD` environment variable), you
|
2016-10-20 17:14:25 +03:00
|
|
|
will also want to expose port 137 and 138 with `-p 137:137/udp -p 138:138/udp`.
|
2016-02-10 22:19:42 +03:00
|
|
|
|
2018-09-23 20:07:46 +03:00
|
|
|
**NOTE2**: there are reports that `-n` and `NMBD` only work if you have the
|
|
|
|
container configured to use the hosts network stack.
|
|
|
|
|
2019-07-06 23:27:43 +03:00
|
|
|
**NOTE3**: optionally supports additional variables starting with the same name,
|
|
|
|
IE `SHARE` also will work for `SHARE2`, `SHARE3`... `SHAREx`, etc.
|
|
|
|
|
2015-01-02 07:03:52 +03:00
|
|
|
## Examples
|
|
|
|
|
|
|
|
Any of the commands can be run at creation with `docker run` or later with
|
2018-02-02 22:29:01 +03:00
|
|
|
`docker exec -it samba samba.sh` (as of version 1.3 of docker).
|
2015-01-02 07:03:52 +03:00
|
|
|
|
2015-08-16 00:10:17 +03:00
|
|
|
### Setting the Timezone
|
|
|
|
|
2019-08-27 13:49:59 +03:00
|
|
|
sudo docker run -it -e TZ=EST5EDT -p 139:139 -p 445:445 -d dperson/samba -p
|
2015-08-16 00:10:17 +03:00
|
|
|
|
2015-01-02 07:03:52 +03:00
|
|
|
### Start an instance creating users and shares:
|
|
|
|
|
2019-08-27 13:49:59 +03:00
|
|
|
sudo docker run -it -p 139:139 -p 445:445 -d dperson/samba -p \
|
2015-01-02 07:03:52 +03:00
|
|
|
-u "example1;badpass" \
|
|
|
|
-u "example2;badpass" \
|
|
|
|
-s "public;/share" \
|
|
|
|
-s "users;/srv;no;no;no;example1,example2" \
|
2018-11-06 02:16:50 +03:00
|
|
|
-s "example1 private share;/example1;no;no;no;example1" \
|
|
|
|
-s "example2 private share;/example2;no;no;no;example2"
|
2015-01-02 07:03:52 +03:00
|
|
|
|
|
|
|
# User Feedback
|
|
|
|
|
2019-08-12 14:20:45 +03:00
|
|
|
## Troubleshooting
|
|
|
|
|
|
|
|
* You get the error `Access is denied` (or similar) on the client and/or see
|
|
|
|
`change_to_user_internal: chdir_current_service() failed!` in the container
|
|
|
|
logs.
|
|
|
|
|
|
|
|
Add the `-p` option to the end of your options to the container, or set the
|
|
|
|
`PERMISSIONS` environment variable.
|
|
|
|
|
2019-08-17 14:56:19 +03:00
|
|
|
sudo docker run -it --name samba -p 139:139 -p 445:445 \
|
|
|
|
-v /path/to/directory:/mount \
|
|
|
|
-d dperson/samba -p
|
|
|
|
|
|
|
|
* High memory usage by samba. Multiple people have reported high memory usage
|
|
|
|
that's never freed by the samba processes. Recommended work around below:
|
|
|
|
|
|
|
|
Add the `-m 512m` option to docker run command, or `mem_limit:` in
|
|
|
|
docker_compose.yml files, IE:
|
|
|
|
|
|
|
|
sudo docker run -it --name samba -m 512m -p 139:139 -p 445:445 \
|
|
|
|
-v /path/to/directory:/mount \
|
|
|
|
-d dperson/samba -p
|
2019-08-12 14:20:45 +03:00
|
|
|
|
2019-08-27 14:00:05 +03:00
|
|
|
* Attempting to connect with the `smbclient` commandline tool. By default samba
|
|
|
|
still tries to use SMB1, which is depriciated and has security issues. This
|
|
|
|
container defaults to SMB2, which for no decernable reason even though it's
|
|
|
|
supported is disabled by default so run the command as `smbclient -m SMB3`, then
|
|
|
|
any other options you would specify.
|
|
|
|
|
2015-01-02 07:03:52 +03:00
|
|
|
## Issues
|
|
|
|
|
|
|
|
If you have any problems with or questions about this image, please contact me
|
2017-08-29 15:46:12 +03:00
|
|
|
through a [GitHub issue](https://github.com/dperson/samba/issues).
|