To quickly setup an FTP server or SMB share using a Docker container instead of fiddling with the system daemons, I’ve found these:
FTP
For bringing up an FTP server, I’ve found Gareth Flower’s vsftpd container:
ftp:
image: garethflowers/ftp-server:latest
restart: unless-stopped
ports:
- 3021:21
- 40000-40009:40000-40009
environment:
FTP_USER: username
FTP_PASS: password
UID: 1001
volumes:
- /path/to/folder:/home/username
Here, it’s important to also map ports 40000 – 40009 for PASV FTP to work. The container automatically creates a directory for the user in /home
– so you have to change the FTP_USER
variable and the volume path.
Samba
For SMB/CIFS, there’s the quick and easy dockurr/samba container:
samba:
image: dockurr/samba:latest
restart: unless-stopped
ports:
- 3445:445
environment:
USER: username
PASS: password
UID: 1001
volumes:
- /path/to/folder:/storage
The data gets mounted into /storage
and the share will be available as Data
. If you specify a port different than 445, make sure to remember it when trying to mount the share. E.g. in this case it would be: smb://hostname:3445/Data
.
Samba – Advanced
If you want complete control over the Samba configuration, there’s ServerContainers/samba:
server:
image: ghcr.io/servercontainers/samba:latest
restart: unless-stopped
network_mode: host
environment:
TZ: Europe/London
MODEL: MacSamba
SAMBA_GLOBAL_STANZA: "vfs objects = acl_xattr catia fruit streams_xattr; fruit:nfs_aces = no; inherit permissions = yes; fruit:model = MacSamba; fruit:posix_rename = yes; fruit:veto_appledouble = no; fruit:wipe_intentionally_left_blank_rfork = yes; fruit:delete_empty_adfiles = yes; fruit:metadata = stream"
SAMBA_GLOBAL_CONFIG_load_SPACE_printers: no
SAMBA_GLOBAL_CONFIG_printing: bsd
SAMBA_GLOBAL_CONFIG_printcap_SPACE_name: /dev/null
SAMBA_GLOBAL_CONFIG_disable_SPACE_spoolss: yes
SAMBA_GLOBAL_CONFIG_min_SPACE_protocol: SMB2
SAMBA_GLOBAL_CONFIG_bind_SPACE_interfaces_SPACE_only: yes
SAMBA_GLOBAL_CONFIG_interfaces: lo eth0
SAMBA_CONF_SERVER_STRING: Docker Host Samba
#SAMBA_CONF_LOG_LEVEL: 3
ACCOUNT_username: password
UID_username: 1000
AVAHI_DISABLE: true
WSDD2_DISABLE: true
#NETBIOS_DISABLE: true
SAMBA_VOLUME_CONFIG_semaphore: "[myshare]; path=/shares/myshare; valid users = username; guest ok = no; read only = no; browseable = yes"
volumes:
- /path/to/folder:/shares/myshare
As you can see, this offers a plethora of configuration options and plays especially nice with network_mode: host
in most cases. Just make sure there’s no avahi and/or smbd running on the host.