dockerdockerfileapacheds

Dockerfile LDAP updates not saved


I'm trying to create docker image extended from a base image with some tweaks. Adding files works fine, running commands however doesn't save. I've been looking at the Dockerfile of the image I'm extending but I'm none the wiser.

My Dockerfile:

FROM openmicroscopy/apacheds:latest

ADD *.ldif /etc/ldifs/
ADD addall.sh /etc/ldifs/addall.sh

RUN /bin/bash /etc/ldifs/addall.sh

the bash script:

#!/bin/bash/

/run.sh &
sleep 20

for file in /etc/ldifs/*.ldif
do
    ldapadd -v -h localhost:10389 -c -x -D uid=admin,ou=system -w secret -f "$file"
done

Would anyone happen to know how I can add items to the ldap and save it as an image?


Solution

  • This wont work, while building the image, the Server is not started. You could create bash script startet when the container is started, where you run the import.

    entrypoint.sh
    
    # check if ldap import already done
    
    # if not - import
    for file in /etc/ldifs/*.ldif
    do
        ldapadd -v -h localhost:10389 -c -x -D uid=admin,ou=system -w secret -f "$file"
    done
    
    # if yes - don't import