Member-only story
Build an OpenLDAP Docker Image That’s Populated With Users
Docker images with predefined object resources
I’ve been working with several services and applications that authenticate users with an LDAP server for the last several months. This meant deploying the LDAP server a couple of times to my local machine and populating the users every single time. I needed to deploy the LDAP server to log in and use my services in my development environment.
LDAP, the Lightweight Directory Access Protocol, is a mature, flexible, and well-supported standards-based mechanism for interacting with directory servers. It’s often used for authentication and storing information about users, groups, and applications, but an LDAP directory server is a fairly general-purpose data store and can be used in a wide variety of applications.
There are a couple of commonly-used implementations for the LDAP protocol, including ApacheDS, OpenLDAP, OpenDJ, and Active Directory.
Populating LDAP
data and users is a time-consuming process. It also depends on the amount of data that needs to be populated. But even with very simple data, having to do the same thing more than once manually motivated me to automate that process — reduce the effort needed to complete the job.
I started looking for a way to help me deploy LDAP servers with populated data. After some digging, I discovered that the LDAP Docker image osixia/openldap
supports bootstrapping the LDAP server with the existing LDAP data. Below are the steps to implement the LDAP
bootstrapping using the docker image osixia/openldap
:
- Prepare a bootstrap file. Create a bootstrap file
ldif
that contains all the needed data that need to be imported to the LDAP server once it’s started. - Add the bootstrap file under the following path inside the custom Docker image
/container/service/sldap/assets/config/bootstrap/ldif/
. - Build the Docker image.
- Deploy
LDAP
server using the custom Docker image.