Dockerized Samba4 Active Directory Domain Controller
7.0K
This repository contains Docker container for a working Samba 4 Active Directory Domain Controller (AC DC).
This container is based on Alpine Linux 3.18 image.
Table of contents:
Are you itching to get your samba-ad-dc container up and running ASAP? Then this section is for you:
Minimal run
$ docker run --name samba-ad-dc \
--cap-add SYS_ADMIN \
--volume SAMBA_VOL \
--env DNS_DOMAIN="my.domain.tld" \
--env ADMIN_PASSWORD="Str0ng_Passw0rd" \
linuxcrafts/samba-ad-dc:latest
samba-ad-dc images are published on Docker Hub: https://hub.docker.com/repository/docker/linuxcrafts/samba-ad-dc
You can refer to images using this naming pattern:
docker run linuxcrafts/samba-ad-dc:[VERSION]
Replace [VERSION] with the numerical version or appropriate tag or leave it blank for default tag latest
For example:
docker run linuxcrafts/samba-ad-dc:v0.11
Samba4-ad-dc may run out of the box but you will probably want to set your own configuration. A static IP, and DNS Domain are recomended, an ADMIN_PASSWORD is mandatory though.
The use of elevated privileges is needed by samba to apply proper permission to SMB (CIFS) shares, which can be accomplished by using the parameter --cap-add SYS_ADMIN when running image
To persist data (such as user accounts, groups or logs) beyond container restarts, you can mount a volume to container's /samba directory. You can learn more about volumes in Docker's Official Documentation
To create a managed volume for container
$ docker volume create CONTAINER_NAME
You can use this parameter for the docker run command then:
--volume=CONTAINER_NAME:container_path
Ex.
--volume=CONTAINER_NAME:/samba
It's recommended for easily management to create a volume group and then add/join samba volumes to it
$ docker volume create --group SAMBA_VOLUMES
$ docker volume create CONTAINER_NAME --group SAMBA_VOLUMES
| NAME | LOCATION | CONTENT |
|---|---|---|
| SAMBA | /samba | Samba settings, logs, data and runtime files |
| BIND-DNS | /bind-dns | Samba integration with bind9 dns service |
| NTP | /ntp_signd | Samba secure socket for NTP |
| USERS | /users | Users' roaming profiles |
DO NOT EDIT /samba/etc/smb.conf, place your custom settings under /samba/etc/smb.conf.d/ . You can use overwrite any previous setting by editing /samba/etc/smb.conf.d/59-custom.conf provided for convienience and 99-custom_shares.conf to add new shares.
You can check smb.conf manual page for more options on Samba Project's official web site
The following environment variables are available for your configuration:
| NAME | DEFAULT VALUE | DESCRIPTION |
|---|---|---|
| DNS_DOMAIN | local.company.tld | DNS Domain |
| DNS_FORWARDER | (empty) | DNS servers that DNS requests will be forwarded to if they can not be handled by Samba itself |
| DNS_REVERSE_ZONE | AUTOGENERATED | Network DNS reverse zone (ex. 0.168.192.in-addr.arpa) |
| WORKGROUP | LOCAL | NetBIOS Domain Name |
| REALM | LOCAL.COMPANY.LTD | Kerberos Realm |
| NETBIOS_NAME | $HOSTNAME | Docker image hostname |
| DNS_BACKEND | SAMBA_INTERNAL | DNS server backend (SAMBA_INTERNAL, BIND9_FLATFILE, BIND9_DLZ) |
| FUNCTION_LEVEL | 2008_R2 | Domain and forest function level ( 2000, 2003, 2008, 2008_R2 ) |
| BACKEND_STORE | tdb | Specify the database backend to be used |
| ENABLE_ROAMING_PROFILES | false | Enable/Disable users roaming profiles |
Samba will need a DNS Domain to work, if not supplied as ENV variable on running the container then this action will be taken in order until $DNS_DOMAIN is defined:
hostname defined dns domain ( hostname -d )SEARCH variable in /etc/resolv.conf ( supplied through --dns-domain parameter to docker run command)ENV $REALM variable is supplied then lowercase its valuesmb.conf for realm value then lowercase| PORT | PROTOCOL | DESCRIPTION |
|---|---|---|
| 53 | TCP/UDP | DNS Server |
| 88 | TCP/UDP | Kerberos Server |
| 135 | TCP | MS RPC client-server communication |
| 389 | TCP/UDP | LDAP Server |
| 445 | TCP | SMB Authentication and File Sharing |
| 464 | TCP/UDP | KPasswd Server |
| 636 | TCP | LDAP over SSL |
| 3268 | TCP | Catalog Server |
| 3269 | TCP | Catalog over SSL |
| 50000 - 55000 | TCP | MS RPC Services |
Here are some example commands to run samba-ad-dc image. Please modify them for your system, and provide configuration files in volumes.
samba-ad-dc with all ENV variables:
$ docker run --name samba-ad-dc \
--cap-add SYS_ADMIN \
--env DNS_DOMAIN="my.domain.tld" \
--env DNS_FORWARDER="192.168.0.2" \
--env WORKGROUP="LOCAL" \
--env NETBIOS_NAME="DC01" \
--env DNS_BACKEND="SAMBA_INTERNAL" \
--env FUNCTION_LEVEL="2008_R2" \
--env ROLE="dc" \
--env BACKEND_STORE="tdb" \
--env ENABLE_USER_PROFILES=false \
--env ADMIN_PASSWORD="Str0ng_Passw0rd" \
linuxcrafts/samba-ad-dc:latest
samba-ad-dc with all volumes:
$ docker run --name samba-ad-dc \
--cap-add SYS_ADMIN \
--volume /srv/samba:/samba \
--volume /srv/bind-dns:/bind-dns \
--volume /srv/ntp_signd:/ntp_signd
--volume /srv/users:/users \
linuxcrafts/samba-ad-dc:latest
The image can be built using the following command:
$ git clone https://github.com/LinuxCrafts/samba-ad-dc.git samba-ad-dc
$ docker build samba-ad-dc \
--build-arg VERSION="custom" \
--build-arg BUILD_DATE=$(date +%s) \
--tag samba-ad-dc:custom
$ docker volume create --group SAMBA_VOLUMES
$ docker volume create --group SAMBA_VOLUMES SAMBA_VOL
$ docker volume create --group SAMBA_VOLUMES BIND9_ZONES
$ docker volume create --group SAMBA_VOLUMES NTP_SIGND
$ docker volume create --group SAMBA_VOLUMES ROAMING_PROFILES
$ docker run --name samba-ad-dc \
--cap-add SYS_ADMIN \
--volume SAMBA_VOL \
--env DNS_DOMAIN="my.domain.tld" \
--env ADMIN_PASSWORD="Str0ng_Passw0rd" \
samba-ad-dc:custom
--cap-add SYS_ADMIN was used.Bugs are tracked on GitHub Issues. In case of trouble, please check there to see if your issue has already been reported. If you spotted it first, help us smash it by providing detailed and welcomed feedback.
Contributions to improve this Docker container are welcome! If you find any issues or have suggestions for enhancements, please submit a pull request or open an issue in the GitHub repository.
This project is licensed under the MIT License. Feel free to use, modify, and distribute this code for your own projects.
The Docker image repository is provided as-is, and users should review and understand the configurations and dependencies before deploying Samba AD DC instances in production environments.
Content type
Image
Digest
sha256:f69bd2028…
Size
47.5 MB
Last updated
over 2 years ago
docker pull linuxcrafts/samba-ad-dc