Docker image for OpenLDAP server on Alpine linux
1.2K
Docker image for OpenLDAP server with parameterized config / init LDIF files.
Create 2 LDIF files: slapd.ldif and init.ldif on a folder such as ./ldap-data.
slapd.ldif file:# Global config:
#
dn: cn=config
objectClass: olcGlobal
cn: config
# If you change this, set pidfile variable in /etc/conf.d/slapd!
olcPidFile: /run/openldap/slapd.pid
olcArgsFile: /run/openldap/slapd.args
#olcReferral: ldap://root.openldap.org
#olcSecurity: ssf=1 update_ssf=112 simple_bind=64
olcDisallows: bind_anon
#olcTLSCertificateFile: /etc/ldap/ldap-server.crt
#olcTLSCertificateKeyFile: /etc/ldap/ldap-server.key
#olcTLSCACertificateFile: /etc/ldap/ca.cert.pem
# Load dynamic backend modules:
#
dn: cn=module,cn=config
objectClass: olcModuleList
cn: module
olcModulepath: /usr/lib/openldap
olcModuleload: back_mdb.so
olcModuleload: ppolicy.so
# Load schemas
#
dn: cn=schema,cn=config
objectClass: olcSchemaConfig
cn: schema
include: file:///etc/openldap/schema/core.ldif
include: file:///etc/openldap/schema/cosine.ldif
include: file:///etc/openldap/schema/nis.ldif
include: file:///etc/openldap/schema/inetorgperson.ldif
include: file:///etc/openldap/schema/ppolicy.ldif
# Frontend settings
#
dn: olcDatabase=frontend,cn=config
objectClass: olcDatabaseConfig
objectClass: olcFrontendConfig
olcDatabase: frontend
olcAccess: to * by * read
olcRequires: authc
# Set a RootPW for the config database so we can bind.
dn: olcDatabase=config,cn=config
objectClass: olcDatabaseConfig
olcDatabase: config
olcRootPW: secret
olcAccess: to * by * none
# LMDB database definitions
#
dn: olcDatabase=mdb,cn=config
objectClass: olcDatabaseConfig
objectClass: olcMdbConfig
olcDatabase: mdb
olcSuffix: dc=example,dc=com
olcRootDN: cn=admin,dc=example,dc=com
olcRootPW: secret
olcDbDirectory: /var/lib/openldap/openldap-data
# Indices to maintain
olcDbIndex: objectClass eq
olcDbIndex: cn,uid eq
olcAccess: to attrs=userPassword by self write by anonymous auth by dn.base="cn=sysadmin,dc=example,dc=com" write by * none
olcAccess: to * by self write by dn.base="cn=sysadmin,dc=example,dc=com" write by * read
# Overlays
#
dn: olcOverlay=ppolicy,olcDatabase={1}mdb,cn=config
objectClass: olcOverlayConfig
objectClass: olcPpolicyConfig
olcOverlay: ppolicy
olcPPolicyDefault: cn=ppolicy,dc=example,dc=com
olcPPolicyHashCleartext: TRUE
olcPPolicyUseLockout: FALSE
init.ldif file:dn: dc=example,dc=com
objectclass: dcObject
objectclass: organization
dc: example
o: EXAMPLE.COM
dn: cn=ppolicy,dc=example,dc=com
objectClass: device
objectClass: pwdPolicy
cn: ppolicy
pwdAttribute: userPassword
pwdCheckQuality: 1
pwdMinAge: 0
pwdMaxAge: 0
pwdMinLength: 5
pwdInHistory: 3
pwdMaxFailure: 5
pwdFailureCountInterval: 30
pwdLockout: TRUE
pwdLockoutDuration: 0
pwdAllowUserChange: TRUE
pwdExpireWarning: 600
pwdGraceAuthNLimit: 3
pwdMustChange: FALSE
pwdSafeModify: FALSE
docker run -d -p 389:389 -e "LOG_LEVEL=768" -v "/d/ldap-data:/etc/ldap" nthachus/ldap-alpine
Prepare docker-compose.yml file:
version: "3"
services:
ldap-server:
image: nthachus/ldap-alpine
volumes:
- "./ldap-data:/etc/ldap:ro"
- ldap-server-conf:/etc/openldap/slapd.d
- ldap-server-data:/var/lib/openldap/openldap-data
environment:
- LOG_LEVEL=768
ports:
- 389:389
- 636:636
volumes:
ldap-server-conf:
ldap-server-data:
And run with command docker-compose up.
docker run -d -p 389:389 -e "SUFFIX=dc=example,dc=com" -e "ROOT_USER=adm" -e "ROOT_PW=xxx" -e "ACCESS_CONTROL=to * by self write by anonymous auth by * read" nthachus/ldap-alpine
Then you can access to that LDAP server with BindDN cn=adm,dc=example,dc=com and password xxx
Content type
Image
Digest
Size
5.6 MB
Last updated
over 4 years ago
docker pull nthachus/ldap-alpine