Samba file server for docker. Provide your own smb.conf
3.7K
docker create itsdaspecialk/samba
docker cp $(docker ps -ql):/etc/samba/smb.conf .
docker rm $(docker ps -ql)
NOTE: Make sure to use passdb backend = tdbsam in the config file, unless you know what you are doing.
docker create itsdaspecialk/samba
docker cp $(docker ps -ql):/etc/samba/smb.conf.example .
docker rm $(docker ps -ql)
docker run -d --name samba \
--net=host \
-v <path/to/share>:<path/to/share> \
-v samba_private:/var/lib/samba \
-v samba_group:/etc/group \
-v samba_passwd:/etc/passwd \
-v samba_shadow:/etc/shadow \
itsdaspecialk/samba
This creates a named volume to store the samba tdb files. If you would rather specify a location for it, replace samba_private with a path above.
Any arguments passed to the container get passed to both smbd AND nmbd. If you would rather only pass parameters to one of the two commands, use the environment variables NARGS and SARGS for nmbd and smbd respectively.
You can use the host groups and users in the samba container, using the following command:
docker run -d ... -v samba_private:/var/lib/samba \
-v /etc/group:/etc/group:ro \
-v /etc/passwd:/etc/passwd:ro \
-v /etc/shadow:/etc/shadow:ro \
itsdaspecialk/samba
If using this method, when adding/modifying users and groups, do so on your host system. You will, however, still need to use smbpasswd -a
NOTE: I have only tried this in Redhat and Centos! Theoretically, it should work on other distros too, as long as there is are root and nobody users and groups
NOTE 2: I highly recommend using the read-only mode, if you choose to use this method.
NOTE: The container must be running for these steps.
For users, Samba uses its own passdb.tdb file to authenticate user passwords, but still uses the standard UNIX user files.
If you are not using the host system /etc/passwd file, you first need to create a user using the following command:
docker exec -it <container_name/hash> useradd -M <username>
Then set the password for samba.
docker exec -it <container_name/hash> smbpasswd -a <username>
First, create the group:
docker exec -it <container_name/hash> groupadd <groupname>
Next, add a user to the group:
docker exec -it <container_name/hash> usermod -a -G <groupname> <username>
If you have an issue, please create an issue on Bitbucket
Content type
Image
Digest
Size
85 MB
Last updated
almost 8 years ago
docker pull itsdaspecialk/samba