Sign inSign up

linuxcrafts/samba-ad-dc

By linuxcrafts

•Updated over 2 years ago

Dockerized Samba4 Active Directory Domain Controller

Image
1

7.0K

linuxcrafts/samba-ad-dc repository overview

⁠Docker Container for Samba4 Active Directory Domain Controller

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:

  1. For Impatients⁠
  2. Using samba-ad-dc from Docker Hub⁠
  3. Building the Image⁠
  4. References⁠
  5. Other⁠

⁠For Impatients

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

⁠Using samba-ad-dc image on Docker Hub

⁠LinuxCrafts Repository on Docker Hub

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

⁠Requirements

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

⁠Volumes

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
NAMELOCATIONCONTENT
SAMBA/sambaSamba settings, logs, data and runtime files
BIND-DNS/bind-dnsSamba integration with bind9 dns service
NTP/ntp_signdSamba secure socket for NTP
USERS/usersUsers' 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⁠

⁠Environment Variables

The following environment variables are available for your configuration:

NAMEDEFAULT VALUEDESCRIPTION
DNS_DOMAINlocal.company.tldDNS Domain
DNS_FORWARDER(empty)DNS servers that DNS requests will be forwarded to if they can not be handled by Samba itself
DNS_REVERSE_ZONEAUTOGENERATEDNetwork DNS reverse zone (ex. 0.168.192.in-addr.arpa)
WORKGROUPLOCALNetBIOS Domain Name
REALMLOCAL.COMPANY.LTDKerberos Realm
NETBIOS_NAME$HOSTNAMEDocker image hostname
DNS_BACKENDSAMBA_INTERNALDNS server backend (SAMBA_INTERNAL, BIND9_FLATFILE, BIND9_DLZ)
FUNCTION_LEVEL2008_R2Domain and forest function level ( 2000, 2003, 2008, 2008_R2 )
BACKEND_STOREtdbSpecify the database backend to be used
ENABLE_ROAMING_PROFILESfalseEnable/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:

  • Look for hostname defined dns domain ( hostname -d )
  • Look for first value of SEARCH variable in /etc/resolv.conf ( supplied through --dns-domain parameter to docker run command)
  • If ENV $REALM variable is supplied then lowercase its value
  • Look into smb.conf for realm value then lowercase
  • Default to my.company.tld

⁠Exposed Ports

PORTPROTOCOLDESCRIPTION
53TCP/UDPDNS Server
88TCP/UDPKerberos Server
135TCPMS RPC client-server communication
389TCP/UDPLDAP Server
445TCPSMB Authentication and File Sharing
464TCP/UDPKPasswd Server
636TCPLDAP over SSL
3268TCPCatalog Server
3269TCPCatalog over SSL
50000 - 55000TCPMS RPC Services

⁠Examples

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

⁠Building the Image

The image can be built using the following command:

⁠Downloading required files
$ git clone https://github.com/LinuxCrafts/samba-ad-dc.git samba-ad-dc
⁠Building your custom image
$ docker build samba-ad-dc \
    --build-arg VERSION="custom" \
    --build-arg BUILD_DATE=$(date +%s) \
    --tag samba-ad-dc:custom
⁠Preparing the Volumes
$ 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 
⁠Running the Image
$ 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

⁠References

⁠Other

⁠Troubleshooting
  • Ports: Ensure that the necessary ports are not being used by other services on your system.
  • Network: Make sure that container is using an static IP and it's not already in use in the network.
  • Permissions: Make sure that the Docker daemon has appropriate permissions to access the necessary directories and ports and --cap-add SYS_ADMIN was used.
⁠Bug Tracker

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.

⁠Maintainer
⁠Contributing

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.

⁠License

This project is licensed under the MIT License⁠. Feel free to use, modify, and distribute this code for your own projects.

⁠Disclaimer

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.

Tag summary

Content type

Image

Digest

sha256:f69bd2028…

Size

47.5 MB

Last updated

over 2 years ago

docker pull linuxcrafts/samba-ad-dc