Skip to content

Instantly share code, notes, and snippets.

@thoughtsunificator
Last active January 24, 2025 19:02
Show Gist options
  • Save thoughtsunificator/6ad8499faaee30900b38025f6ad2d1c3 to your computer and use it in GitHub Desktop.
Save thoughtsunificator/6ad8499faaee30900b38025f6ad2d1c3 to your computer and use it in GitHub Desktop.
Samba 4.20 as a containerized server
services:
server:
restart: unless-stopped
build:
context: .
args:
- SAMBA_USER=${SAMBA_USER:-cloud}
- SAMBA_PASSWORD=${SAMBA_PASSWORD:-r7YOFnt/m49lROpYiGSAqJhkJAgoymV0F8Rnq1aZOCI=}
volumes:
- /mnt/windows:/mount
- ./smb.conf:/etc/samba/smb.conf
ports:
- 445:445
# 3.21.1
FROM alpine@sha256:b97e2a89d0b9e4011bb88c02ddf01c544b8c781acf1f4d559e7c8f12f1047ac3
ARG SAMBA_USER=cloud
ARG SAMBA_PASSWORD="r7YOFnt/m49lROpYiGSAqJhkJAgoymV0F8Rnq1aZOCI="
RUN apk add --update \
samba-common-tools=4.20.6-r1 \
samba-client=4.20.6-r1 \
samba-server=4.20.6-r1 \
&& rm -rf /var/cache/apk/*
RUN adduser -D -g $SAMBA_USER $SAMBA_USER \
&& echo -e "$SAMBA_PASSWORD\n$SAMBA_PASSWORD" | smbpasswd -a $SAMBA_USER
EXPOSE 445/tcp
ENTRYPOINT ["smbd", "--foreground", "--debug-stdout", "--no-process-group"]
# samba-server-4.20.6-r1
# This is the main Samba configuration file. You should read the
# smb.conf(5) manual page in order to understand the options listed
# here. Samba has a huge number of configurable options (perhaps too
# many!) most of which are not shown in this example
#
# For a step to step guide on installing, configuring and using samba,
# read the Samba-HOWTO-Collection. This may be obtained from:
# http://www.samba.org/samba/docs/Samba-HOWTO-Collection.pdf
#
# Many working examples of smb.conf files can be found in the
# Samba-Guide which is generated daily and can be downloaded from:
# http://www.samba.org/samba/docs/Samba-Guide.pdf
#
# Any line which starts with a ; (semi-colon) or a # (hash)
# is a comment and is ignored. In this example we will use a #
# for commentry and a ; for parts of the config file that you
# may wish to enable
#
# NOTE: Whenever you modify this file you should run the command "testparm"
# to check that you have not made any basic syntactic errors.
#
#======================= Global Settings =====================================
[global]
# workgroup = NT-Domain-Name or Workgroup-Name, eg: MIDEARTH
workgroup = MIDEARTH
# server string is the equivalent of the NT Description field
server string = myserver
# Server role. Defines in which mode Samba will operate. Possible
# values are "standalone server", "member server", "classic primary
# domain controller", "classic backup domain controller", "active
# directory domain controller".
#
# Most people will want "standalone server" or "member server".
# Running as "active directory domain controller" will require first
# running "samba-tool domain provision" to wipe databases and create a
# new domain.
server role = standalone server
# With user-level security a client must first "log-on" with a valid username and password (which can be mapped using the username map parameter).
security = user
log level = 1
dns proxy = no
[media]
path = /mount
valid users = cloud
force user = cloud
force group = cloud
writable = yes
printable = no
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment