openLDAP Multi master replication in docker

Hi All,
I am a bit newbe with Docker and this might be a schoolboy question but I cant make any progress.

I have all working according the instruction provided in the link below:

but I do not understand this instruction according to “Multi master replication” Do I need to simply adjust to my hostname and execute?

Could anyone help please?

Multi master replication

Quick example, with the default config.

#Create the first ldap server, save the container id in LDAP_CID and get its IP:
**LDAP_CID=$(docker run --hostname --env LDAP_REPLICATION=true --detach osixia/openldap:1.5.0)**
**LDAP_IP=$(docker inspect -f "{{ .NetworkSettings.IPAddress }}" $LDAP_CID)**

#Create the second ldap server, save the container id in LDAP2_CID and get its IP:
**LDAP2_CID=$(docker run --hostname --env LDAP_REPLICATION=true --detach osixia/openldap:1.5.0)**
**LDAP2_IP=$(docker inspect -f "{{ .NetworkSettings.IPAddress }}" $LDAP2_CID)**

#Add the pair "ip hostname" to /etc/hosts on each containers,
#because and are fake hostnames
docker exec $LDAP_CID bash -c "echo $LDAP2_IP >> /etc/hosts"
docker exec $LDAP2_CID bash -c "echo $LDAP_IP >> /etc/hosts"

That’s it! But a little test to be sure:

Add a new user “billy” on the first ldap server

docker exec $LDAP_CID ldapadd -x -D "cn=admin,dc=example,dc=org" -w admin -f /container/service/slapd/assets/test/new-user.ldif -H ldap:// -ZZ

Hello Tomasz and welcome :slight_smile:

The mentioned example is (in my eyes) only for testing as it relies on the docker-container’s ip-addresses which might change at the container’s next startup.

Do you really want to test a multi-master-replication on one single Docker-host? Or what exactly do you want to achieve?

Best regards

Hi Matt,

Thank you for your reply. Let me explain.

  1. I installed two Ubuntu machines
  2. Next, I installed docker on each and on the top of that openLDAP, phpldapadmin containers in line with the instruction mentioned above. They are working fine as expected.

Docker 1) hostname = ldap1-master.domain.local (IP=
Docker 2) hostname = ldap2-replica.domain.local (IP=

Now, I need to have a replication between both openLDAPs. All instructions I can find are on non-docker installs and I do not know where the config files are located in docker. It looks it must be much simpler but I dont know how to use the example provided above.

Basically, I would like to have both openLDAP synchrinized.