Add examples, update README and LICENSE
This commit is contained in:
parent
386e63be60
commit
962674edb1
3
.dockerignore
Normal file
3
.dockerignore
Normal file
@ -0,0 +1,3 @@
|
|||||||
|
LICENSE*
|
||||||
|
README*
|
||||||
|
examples
|
21
LICENSE
Normal file
21
LICENSE
Normal file
@ -0,0 +1,21 @@
|
|||||||
|
The MIT License (MIT)
|
||||||
|
|
||||||
|
Copyright (c) 2020 Vladimir "fat0troll" Hodakov
|
||||||
|
|
||||||
|
Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||||
|
of this software and associated documentation files (the "Software"), to deal
|
||||||
|
in the Software without restriction, including without limitation the rights
|
||||||
|
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||||
|
copies of the Software, and to permit persons to whom the Software is
|
||||||
|
furnished to do so, subject to the following conditions:
|
||||||
|
|
||||||
|
The above copyright notice and this permission notice shall be included in all
|
||||||
|
copies or substantial portions of the Software.
|
||||||
|
|
||||||
|
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||||
|
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||||
|
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||||
|
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||||
|
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||||
|
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
||||||
|
SOFTWARE.
|
49
README.md
49
README.md
@ -1,3 +1,50 @@
|
|||||||
# Samba + Avahi in Docker container
|
# Samba + Avahi in Docker container
|
||||||
|
|
||||||
This repository contains sources for fat0troll/samba-with-avahi.
|
This repository contains sources for [fat0troll/samba-with-avahi](https://hub.docker.com/repository/docker/fat0troll/samba-with-avahi) - Docker container for as simple as possible
|
||||||
|
sharing experience. After tiny tinkering you will get running Samba, ready to be advertized to
|
||||||
|
local network via Avahi (and to host Time Machine backups for example).
|
||||||
|
|
||||||
|
**Note 1**: This container requires `host` or `macvlan` network type, and will **not** work in `bridge` (default mode) network. See `examples/docker-compose.yml` for details. If you can/want to make it work in `bridge` mode, PRs are welcome (see Note 3).
|
||||||
|
|
||||||
|
**Note 2**: This container is tested under Linux and built for linux/amd64 only. That's because this is the only architecture used in my servers at the time. If you want to, you can send PR with changes for building image for other architectures.
|
||||||
|
|
||||||
|
**Note 3**: The [repo](https://github.com/fat0troll/samba-with-avahi) on Github is a mirror, and main development is done at [source.hodakov.me](https://source.hodakov.me/containers/samba-with-avahi). You may send PR where you want: I will accept on both, but will merge it manually, if it's from Github.
|
||||||
|
|
||||||
|
## Preparations
|
||||||
|
|
||||||
|
There is no custom scripts or similar, this container consumes standart configuration files from Samba and Avahi. Example configuration file for Samba is included in `examples/samba` directory. Due to licensing issues Avahi example configuration files isn't included in this repository, so you need to grab it manually. You can do this by passing these commands:
|
||||||
|
|
||||||
|
```
|
||||||
|
$ docker create --name avahi-config fat0troll/samba-with-avahi
|
||||||
|
$ docker cp avahi-config:/etc/avahi .
|
||||||
|
$ docker rm avahi-config
|
||||||
|
```
|
||||||
|
|
||||||
|
In the generated config files for Avahi you may add/remove your services (under `services` folder), and you **should** disable DBus otherwise it will not start at all. Add this to `avahi-daemon.conf` first section:
|
||||||
|
|
||||||
|
```
|
||||||
|
enable-dbus=no
|
||||||
|
```
|
||||||
|
|
||||||
|
## Environment variables
|
||||||
|
|
||||||
|
There is one set of environment variables this container consumes: `USER*` (where `*` is replaced with a number, but technically it may be everything). The format of variables is `username,group,UID`: you can create inside a container user with your host UID and it will write files to your share locations seamlessly with host. Example of `env` file with some defined users is located in `examples` directory.
|
||||||
|
|
||||||
|
## Starting from command-line example
|
||||||
|
|
||||||
|
```
|
||||||
|
$ docker run -it --name samba --net=host \
|
||||||
|
-v /path/to/avahi/configs:/etc/avahi \
|
||||||
|
-v /path/to/samba/configs:/etc/samba \
|
||||||
|
-v /path/to/samba/lib:/var/lib/samba \
|
||||||
|
-v /path/to/shares:/data \
|
||||||
|
fat0troll:avahi-with-docker
|
||||||
|
```
|
||||||
|
|
||||||
|
## Starting from docker stack example
|
||||||
|
|
||||||
|
See `examples/docker-compose.yaml`. This file may be deployed by command:
|
||||||
|
|
||||||
|
```
|
||||||
|
$ docker stack deploy -c examples/docker-compose.yaml samba
|
||||||
|
```
|
70
examples/docker-compose.yaml
Normal file
70
examples/docker-compose.yaml
Normal file
@ -0,0 +1,70 @@
|
|||||||
|
version: "3.7"
|
||||||
|
|
||||||
|
networks:
|
||||||
|
host:
|
||||||
|
external: true
|
||||||
|
name: host
|
||||||
|
|
||||||
|
volumes:
|
||||||
|
avahicfg:
|
||||||
|
name: avahicfg
|
||||||
|
driver: local
|
||||||
|
driver_opts:
|
||||||
|
type: none
|
||||||
|
device: ./avahi
|
||||||
|
o: bind,ro
|
||||||
|
sambacfg:
|
||||||
|
name: sambacfg
|
||||||
|
driver: local
|
||||||
|
driver_opts:
|
||||||
|
type: none
|
||||||
|
device: ./samba
|
||||||
|
o: bind,ro
|
||||||
|
sambadb:
|
||||||
|
name: sambadb
|
||||||
|
driver: local
|
||||||
|
driver_opts:
|
||||||
|
type: none
|
||||||
|
device: ./sambalib
|
||||||
|
o: bind
|
||||||
|
storage:
|
||||||
|
name: storage
|
||||||
|
driver: local
|
||||||
|
driver_opts:
|
||||||
|
type: none
|
||||||
|
device: ./data
|
||||||
|
o: bind
|
||||||
|
|
||||||
|
services:
|
||||||
|
samba:
|
||||||
|
image: fat0troll/samba-with-avahi:latest
|
||||||
|
env_file:
|
||||||
|
- ./env
|
||||||
|
deploy:
|
||||||
|
replicas: 1
|
||||||
|
resources:
|
||||||
|
limits:
|
||||||
|
memory: 512M
|
||||||
|
reservations:
|
||||||
|
memory: 512M
|
||||||
|
restart_policy:
|
||||||
|
condition: any
|
||||||
|
delay: 5s
|
||||||
|
max_attempts: 3
|
||||||
|
window: 120s
|
||||||
|
networks:
|
||||||
|
- host
|
||||||
|
tty: true
|
||||||
|
volumes:
|
||||||
|
- type: volume
|
||||||
|
source: storage
|
||||||
|
target: /data
|
||||||
|
- type: volume
|
||||||
|
source: avahicfg
|
||||||
|
target: /etc/avahi
|
||||||
|
- type: volume
|
||||||
|
source: sambacfg
|
||||||
|
target: /etc/samba
|
||||||
|
- type: volume
|
||||||
|
source: sambadb
|
||||||
|
target: /var/lib/samba
|
3
examples/env
Normal file
3
examples/env
Normal file
@ -0,0 +1,3 @@
|
|||||||
|
USER0=fat0troll,users,1000
|
||||||
|
USER1=pztrn,users,1001
|
||||||
|
USER2=whatever,users,1002
|
33
examples/samba/smb.conf
Normal file
33
examples/samba/smb.conf
Normal file
@ -0,0 +1,33 @@
|
|||||||
|
[global]
|
||||||
|
netbios name = dockerhost
|
||||||
|
interfaces = 192.168.0.1/24
|
||||||
|
bind interfaces only = yes
|
||||||
|
server string = DOCKERHOST
|
||||||
|
workgroup = WORKGROUP
|
||||||
|
guest account = guest
|
||||||
|
passdb backend = tdbsam
|
||||||
|
security = user
|
||||||
|
map to guest = bad user
|
||||||
|
guest ok = yes
|
||||||
|
timestamp logs = no
|
||||||
|
preserve case = yes
|
||||||
|
short preserve case = yes
|
||||||
|
log level = 3
|
||||||
|
smb encrypt = disabled
|
||||||
|
fruit:aapl = yes
|
||||||
|
fruit:resource = xattr
|
||||||
|
|
||||||
|
[timemachine]
|
||||||
|
path = /data/timemachine
|
||||||
|
browseable = yes
|
||||||
|
read only = no
|
||||||
|
guest ok = no
|
||||||
|
ea support = yes
|
||||||
|
inherit acls = yes
|
||||||
|
vfs objects = catia fruit streams_xattr
|
||||||
|
fruit:time machine = yes
|
||||||
|
fruit:time machine max size = 1024 G
|
||||||
|
fruit:advertise_fullsync = true
|
||||||
|
spotlight = yes
|
||||||
|
veto files = /.apdisk/.DS_Store/.TemporaryItems/.Trashes/desktop.ini/ehthumbs.db/Network Trash Folder/Temporary Items/Thumbs.db/
|
||||||
|
delete veto files = yes
|
Reference in New Issue
Block a user