Skip to content

Commit ffad09b

Browse files
committed
Merge branch 'datacticapertti-explicit-openldap-uid-gid' into release-1.1.10
2 parents a648a9e + fb8535f commit ffad09b

File tree

2 files changed

+17
-1
lines changed

2 files changed

+17
-1
lines changed

README.md

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -95,6 +95,17 @@ By default the admin has the password **admin**. All those default settings can
9595
The directories `/var/lib/ldap` (LDAP database files) and `/etc/ldap/slapd.d` (LDAP config files) are used to persist the schema and data information, and should be mapped as volumes, so your ldap files are saved outside the container (see [Use an existing ldap database](#use-an-existing-ldap-database)). However it can be useful to not use volumes,
9696
in case the image should be delivered complete with test data - this is especially useful when deriving other images from this one.
9797

98+
The default uid and gid used by the image may map to surprising
99+
counterparts in the host. If you need to match uid and gid in the
100+
container and in the host, you can use build parameters
101+
`LDAP_OPENLDAP_UID` and `LDAP_OPENLDAP_GID` to set uid and gid
102+
explicitly:
103+
104+
docker build --build-arg LDAP_OPENLDAP_GID=1234 --build-arg LDAP_OPENLDAP_UID=2345 -t my_ldap_image .
105+
docker run --name my_ldap_container -d my_ldap_image
106+
# this should output uid=2345(openldap) gid=1234(openldap) groups=1234(openldap)
107+
docker exec my_ldap_container id openldap
108+
98109
For more information about docker data volume, please refer to:
99110

100111
> [https://docs.docker.com/engine/tutorials/dockervolumes/](https://docs.docker.com/engine/tutorials/dockervolumes/)

image/Dockerfile

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,8 +3,13 @@
33
FROM osixia/light-baseimage:1.1.1
44
MAINTAINER Bertrand Gouny <[email protected]>
55

6+
ARG LDAP_OPENLDAP_GID
7+
ARG LDAP_OPENLDAP_UID
8+
69
# Add openldap user and group first to make sure their IDs get assigned consistently, regardless of whatever dependencies get added
7-
RUN groupadd -r openldap && useradd -r -g openldap openldap
10+
# If explicit uid or gid is given, use it.
11+
RUN if [ -z "${LDAP_OPENLDAP_GID}" ]; then groupadd -r openldap; else groupadd -r -g ${LDAP_OPENLDAP_GID} openldap; fi \
12+
&& if [ -z "${LDAP_OPENLDAP_UID}" ]; then useradd -r -g openldap openldap; else useradd -r -g openldap -u ${LDAP_OPENLDAP_UID} openldap; fi
813

914
# Install OpenLDAP, ldap-utils and ssl-tools from baseimage and clean apt-get files
1015
# sources: https://github.com/osixia/docker-light-baseimage/blob/stable/image/tool/add-service-available

0 commit comments

Comments
 (0)