Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/aguslr/docker-samba
Set up a Samba server to share files over the network
https://github.com/aguslr/docker-samba
cifs docker podman samba smb
Last synced: 3 days ago
JSON representation
Set up a Samba server to share files over the network
- Host: GitHub
- URL: https://github.com/aguslr/docker-samba
- Owner: aguslr
- License: gpl-3.0
- Created: 2023-04-28T14:54:24.000Z (over 1 year ago)
- Default Branch: main
- Last Pushed: 2024-05-28T10:13:46.000Z (8 months ago)
- Last Synced: 2024-11-24T02:14:04.636Z (2 months ago)
- Topics: cifs, docker, podman, samba, smb
- Language: Shell
- Homepage:
- Size: 63.5 KB
- Stars: 1
- Watchers: 2
- Forks: 1
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
[aguslr/docker-samba][1]
========================[![docker-pulls](https://img.shields.io/docker/pulls/aguslr/samba)](https://hub.docker.com/r/aguslr/samba) [![image-size](https://img.shields.io/docker/image-size/aguslr/samba/latest)](https://hub.docker.com/r/aguslr/samba)
This *Docker* image sets up *Samba* inside a docker container.
> **[Samba][2]** is a free software re-implementation of the SMB networking
> protocol.Installation
------------To use *docker-samba*, follow these steps:
1. Clone and start the container:
docker run -p 445:445 \
-e SAMBA_USER=bob \
-e SAMBA_PASS=123456 \
-v "${PWD}"/home:/home \
docker.io/aguslr/samba:latest2. Configure your *Samba* client software to connect to your *Samba* server's IP
address with user `SAMBA_USER`.### Variables
The image is configured using environment variables passed at runtime. All these
variables are prefixed by `SAMBA_`.| Variable | Function | Default | Required |
| :----------- | :--------------------- | :------------ | -------- |
| `USER` | Username of Samba user | `smbuser` | N |
| `PASS` | Password of Samba user | autogenerated | N |
| `UID` | UID of Samba user | 11000 | N |
| `PASSWDFILE` | Valid `smbpasswd` file | empty | N |
| `USERSFILE` | File with user list | empty | N |### Adding users
A default user is created with username `smbuser` (or the value of `SAMBA_USER`)
and an autogenerated password if none is provided with the variable
`SAMBA_PASS`. To see the autogenerated password, check the log for the
container:docker logs | grep '^Password'
#### Importing `smbpasswd` file
Alternatively, if a [valid `smbpasswd`][3] file is provided, its users will be
added to the system and it will be imported using [`pdbedit`][4]. The same tool
can be used to export the file from a working Samba setup:pdbedit -e smbpasswd:/tmp/smbpasswd
#### Parsing user file
A third option that provides finer control is provided. Using the variable
`SAMBA_USERSFILE`, the path to a file with users' information can be passed to
the container.This file should have one user per line in the format `UID:NAME:GROUP:NTHASH`.
For example:1000:smbuser:users:32ED87BDB5FDC5E9CBA88547376818D4
The command tool [`mkpasswd`][5] can be used to get NT-Hashes from plain text
passwords:mkpasswd --method=nt 123456
This command would ouput as used in the example above:
$3$$32ed87bdb5fdc5e9cba88547376818d4
### Custom `smb.conf`
To configure additional shares or parameters, we can add these to a `smb.conf`
file:[Data]
path = /data
comment = Data directory
available = yes
browseable = yes
read only = yes
valid users = @users @nogroup
write list = @usersThen, we can go ahead and mount it as follows:
docker run -p 445:445 \
-e SAMBA_PASSWDFILE=/tmp/smbpasswd \
-v "${PWD}"/smbpasswd:/tmp/smbpasswd \
-v "${PWD}"/data:/data \
-v "${PWD}"/home:/home \
-v "${PWD}"/smb.conf:/etc/samba/includes.conf \
docker.io/aguslr/samba:latestBuild locally
-------------Instead of pulling the image from a remote repository, you can build it locally:
1. Clone the repository:
git clone https://github.com/aguslr/docker-samba.git
2. Change into the newly created directory and use `docker-compose` to build and
launch the container:cd docker-samba && docker-compose up --build -d
[1]: https://github.com/aguslr/docker-samba
[2]: https://www.samba.org/
[3]: https://www.samba.org/samba/docs/current/man-html/smbpasswd.5.html
[4]: https://www.samba.org/samba/docs/current/man-html/pdbedit.8.html
[5]: https://www.mkpasswd.net/