Skip to content

Commit 2f7ea27

Browse files
committed
Merge branch 'hotfix-0.10.2' into stable
2 parents 2c098f3 + 35dba66 commit 2f7ea27

37 files changed

+486
-131
lines changed

CHANGELOG.md

Lines changed: 28 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,30 @@
1-
## 0.10.1 (release date: 2015-05-17)
2-
- Add ldapi
3-
- Add custom ldap schema
4-
- Auto convert .schema to .ldif
5-
- Fixes issues #2 #3
1+
# Changelog
62

7-
## 0.10.0 (release date: 2015-03-03)
3+
## 0.10.2
4+
5+
- New features:
6+
- Bootstrap config, only on non existing slapd config
7+
- Limit max open file descriptors to fix slapd memory usage (#9)
8+
- Don't disable network access from outside (#8)
9+
- Make log level configurable via environment variable (#7)
10+
- Support for ldaps (#10)
11+
12+
13+
- Fixes:
14+
- Unable to start container with the following invocation. (#6)
15+
16+
## 0.10.1
17+
18+
- New features:
19+
- Add ldapi
20+
- Add ldapi
21+
- Add custom ldap schema
22+
- Auto convert .schema to .ldif
23+
24+
25+
- Fixes :
26+
- Docker VOLUME is not needed to be able to stop a container without losing data (#2)
27+
- starting from old data (#3)
28+
29+
## 0.10.0
830
- New version initial release

Makefile

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
NAME = osixia/openldap
2-
VERSION = 0.10.1
2+
VERSION = 0.10.2
33

44
.PHONY: all build test tag_latest release
55

@@ -19,4 +19,3 @@ release: build test tag_latest
1919
@if ! head -n 1 CHANGELOG.md | grep -q 'release date'; then echo 'Please note the release date in Changelog.md.' && false; fi
2020
docker push $(NAME)
2121
@echo "*** Don't forget to run 'twgit release/hotfix finish' :)"
22-

README.md

Lines changed: 90 additions & 34 deletions
Original file line numberDiff line numberDiff line change
@@ -6,29 +6,27 @@ A docker image to run OpenLDAP.
66
Fork of Nick Stenning docker-slapd :
77
https://github.com/nickstenning/docker-slapd
88

9-
Add support of tls. Use docker 1.5.0
9+
Add support of TLS and multi master replication.
1010

1111
## Quick start
1212
Run OpenLDAP docker image :
1313

14-
docker run -d osixia/openldap
15-
14+
docker run -h ldap.example.org -d osixia/openldap
15+
1616
This start a new container with a OpenLDAP server running inside.
1717
The odd string printed by this command is the `CONTAINER_ID`.
1818
We are going to use this `CONTAINER_ID` to execute some commands inside the container.
1919

20-
Wait 1 or 2 minutes the container startup to be completed.
21-
2220
Then run a terminal on this container,
2321
make sure to replace `CONTAINER_ID` by your container id :
2422

2523
docker exec -it CONTAINER_ID bash
2624

27-
You should now be in the container terminal,
25+
You should now be in the container terminal,
2826
and we can search on the ldap server :
29-
30-
ldapsearch -x -h 127.0.0.1 -b dc=example,dc=org -D "cn=admin,dc=example,dc=org" -w admin
31-
27+
28+
ldapsearch -x -h ldap.example.org -b dc=example,dc=org -D "cn=admin,dc=example,dc=org" -w admin
29+
3230
This should output :
3331

3432
# extended LDIF
@@ -38,17 +36,17 @@ This should output :
3836
# filter: (objectclass=*)
3937
# requesting: ALL
4038
#
41-
39+
4240
[...]
4341

4442
# numResponses: 3
4543
# numEntries: 2
46-
44+
4745
if you have the following error, OpenLDAP is not started yet, wait some time.
4846

4947
ldap_sasl_bind(SIMPLE): Can't contact LDAP server (-1)
50-
51-
48+
49+
5250
## Examples
5351

5452
### Create new ldap server
@@ -58,7 +56,7 @@ It will create an empty ldap for the compagny **Example Inc.** and the domain **
5856

5957
By default the admin has the password **admin**. All those default settings can be changed at the docker command line, for example :
6058

61-
docker run -e LDAP_ORGANISATION="My Compagny" -e LDAP_DOMAIN="my-compagny.com" \
59+
docker run -h ldap.example.org -e LDAP_ORGANISATION="My Compagny" -e LDAP_DOMAIN="my-compagny.com" \
6260
-e LDAP_ADMIN_PASSWORD="JonSn0w" -d osixia/openldap
6361

6462
#### Data persitance
@@ -71,15 +69,15 @@ For more information about docker data volume, please refer to :
7169

7270
> [https://docs.docker.com/userguide/dockervolumes/](https://docs.docker.com/userguide/dockervolumes/)
7371
74-
72+
7573
### Use an existing ldap database
7674

77-
This can be achieved by mounting host directories as volume.
75+
This can be achieved by mounting host directories as volume.
7876
Assuming you have a LDAP database on your docker host in the directory `/data/slapd/database`
7977
and the corresponding LDAP config files on your docker host in the directory `/data/slapd/config`
8078
simply mount this directories as a volume to `/var/lib/ldap` and `/etc/ldap/slapd.d`:
8179

82-
docker run -v /data/slapd/database:/var/lib/ldap \
80+
docker run -h ldap.example.org -v /data/slapd/database:/var/lib/ldap \
8381
-v /data/slapd/config:/etc/ldap/slapd.d
8482
-d osixia/openldap
8583

@@ -89,36 +87,86 @@ You can also use data volume containers. Please refer to :
8987
### Using TLS
9088

9189
#### Use autogenerated certificate
92-
By default TLS is enable, a certificate is created for the CN (common name) ldap.example.org. To work properly on your server adjust SERVER_NAME environment variable to match the ldap server CN.
90+
By default TLS is enable, a certificate is created with the container hostname (set by -h option eg: ldap.example.org).
9391

94-
docker run -e SERVER_NAME=ldap.my-compagny.com -d osixia/openldap
92+
docker run -h ldap.example.org -e SERVER_NAME=ldap.my-compagny.com -d osixia/openldap
9593

9694
#### Use your own certificate
9795

9896
Add your custom certificate, private key and CA certificate in the directory **image/service/slapd/assets/ssl** adjust filename in **image/env.yml** and rebuild the image ([see manual build](#manual-build)).
9997

100-
Or you can set your custom certificate at run time, by mouting your a directory containing thoses files to **/osixia/slapd/ssl** and adjust there name with the following environment variables :
98+
Or you can set your custom certificate at run time, by mouting a directory containing thoses files to **/osixia/slapd/assets/ssl** and adjust there name with the following environment variables :
10199

102-
docker run -v /path/to/certifates:/osixia/slapd/ssl \
100+
docker run -h ldap.example.org -v /path/to/certifates:/osixia/slapd/assets/ssl \
103101
-e SSL_CRT_FILENAME=my-ldap.crt \
104102
-e SSL_KEY_FILENAME=my-ldap.key \
105103
-e SSL_CA_CRT_FILENAME=the-ca.crt \
106104
-d osixia/openldap
107-
105+
108106
#### Disable TLS
109107
Add -e USE_TLS=false to the run command :
110108

111-
docker run -e USE_TLS=false -d osixia/openldap
109+
docker run -h ldap.example.org -e USE_TLS=false -d osixia/openldap
110+
111+
### Multi master replication
112+
Quick example, with the default config.
113+
114+
Create the first ldap server, save the container id in LDAP_CID and get its IP:
115+
116+
LDAP_CID=$(docker run -h ldap.example.org -e USE_REPLICATION=true -d osixia/openldap)
117+
LDAP_IP=$(docker inspect -f "{{ .NetworkSettings.IPAddress }}" $LDAP_CID)
118+
119+
Create the second ldap server, save the container id in LDAP2_CID and get its IP:
120+
121+
LDAP2_CID=$(docker run -h ldap2.example.org -e USE_REPLICATION=true -d osixia/openldap)
122+
LDAP2_IP=$(docker inspect -f "{{ .NetworkSettings.IPAddress }}" $LDAP2_CID)
123+
124+
Add the pair "ip hostname" to /etc/hosts on each containers,
125+
beacause ldap.example.org and ldap2.example.org are fake hostnames
126+
127+
docker exec $LDAP_CID /osixia/test/add-host.sh $LDAP2_IP ldap2.example.org
128+
docker exec $LDAP2_CID /osixia/test/add-host.sh $LDAP_IP ldap.example.org
129+
130+
We reload slapd to let him take into consideration /etc/hosts changes
131+
132+
docker exec $LDAP_CID pkill slapd
133+
docker exec $LDAP2_CID pkill slapd
134+
135+
That's it ! But a litle test to be sure :
136+
137+
Add a new user "billy" on the first ldap server
138+
139+
docker exec $LDAP_CID ldapadd -x -D "cn=admin,dc=example,dc=org" -w admin -f /osixia/test/new-user.ldif -h ldap.example.org -ZZ
140+
141+
Search on the second ldap server, and billy should show up !
142+
143+
docker exec $LDAP2_CID ldapsearch -x -h ldap2.example.org -b dc=example,dc=org -D "cn=admin,dc=example,dc=org" -w admin -ZZ
144+
145+
[...]
146+
147+
# billy, example.org
148+
dn: uid=billy,dc=example,dc=org
149+
uid: billy
150+
cn: billy
151+
sn: 3
152+
objectClass: top
153+
objectClass: posixAccount
154+
objectClass: inetOrgPerson
155+
[...]
156+
112157

113158
## Administrate your ldap server
114159
If you are looking for a simple solution to administrate your ldap server you can take a look at our phpLDAPadmin docker image :
115160
> [osixia/phpldapadmin](https://github.com/osixia/docker-phpLDAPadmin)
116161
117162
## Environment Variables
118163

119-
Environement variables defaults are set in **image/env.yml**. You can modify environment variable values directly in this file and rebuild the image ([see manual build](#manual-build)) or you can override those values at run time with -e argument. See example below.
164+
Environement variables defaults are set in **image/env.yml**. You can modify environment variable values directly in this file and rebuild the image ([see manual build](#manual-build)). You can also override those values at run time with -e argument or by setting your own env.yml file as a docker volume to `/etc/env.yml`. See examples below.
165+
166+
General container configuration :
167+
- **LDAP_LOG_LEVEL**: Slap log level. defaults to `-1`. See table 5.1 in http://www.openldap.org/doc/admin24/slapdconf2.html for the available log levels.
120168

121-
Required for new ldap server :
169+
Required and used for new ldap server only :
122170
- **LDAP_ORGANISATION**: Organisation name. Defaults to `Example Inc.`
123171
- **LDAP_DOMAIN**: Ldap domain. Defaults to `example.org`
124172
- **LDAP_ADMIN_PASSWORD** Admin password. Defaults to `admin`
@@ -128,15 +176,25 @@ TLS options :
128176
- **SSL_CRT_FILENAME**: Ldap ssl certificate filename. Defaults to `ldap.crt`
129177
- **SSL_KEY_FILENAME**: Ldap ssl certificate private key filename. Defaults to `ldap.key`
130178
- **SSL_CA_CRT_FILENAME**: Ldap ssl CA certificate filename. Defaults to `ca.crt`
131-
- **SERVER_NAME**: Use by autogenerated certificate: Server CN. Defaults to `ldap.example.org`
179+
180+
Replication options :
181+
- **USE_REPLICATION**: Add openldap replication capabilities. Defaults to `false`
182+
- **REPLICATION_CONFIG_SYNCPROV**: olcSyncRepl options used for the config database. Without **rid** and **provider** which are automaticaly added based on REPLICATION_HOSTS. Defaults to `binddn="cn=admin,cn=config" bindmethod=simple credentials=$LDAP_CONFIG_PASSWORD searchbase="cn=config" type=refreshAndPersist retry="5 5 300 5" timeout=1 starttls=critical`
183+
- **REPLICATION_HDB_SYNCPROV**: olcSyncRepl options used for the HDB database. Without **rid** and **provider** which are automaticaly added based on REPLICATION_HOSTS. Defaults to `binddn="cn=admin,$BASE_DN" bindmethod=simple credentials=$LDAP_ADMIN_PASSWORD searchbase="$BASE_DN" type=refreshAndPersist interval=00:00:00:10 retry="5 5 300 5" timeout=1 starttls=critical`
184+
- **REPLICATION_HOSTS**: list of replication hosts, must contains the current container hostname set by -h on docker run command. Defaults to `['ldap://ldap.example.org', 'ldap://ldap2.example.org']`
132185

133186
### Set environment variables at run time :
134187

135188
Environment variable can be set directly by adding the -e argument in the command line, for example :
136-
137-
docker run -e LDAP_ORGANISATION="My Compagny" -e LDAP_DOMAIN="my-compagny.com" \
189+
190+
docker run -h ldap.example.org -e LDAP_ORGANISATION="My Compagny" -e LDAP_DOMAIN="my-compagny.com" \
138191
-e LDAP_ADMIN_PASSWORD="JonSn0w" -d osixia/openldap
139192

193+
Or by setting your own `env.yml` file as a docker volume to `/etc/env.yml`
194+
195+
docker run -h ldap.example.org -v /data/my-ldap-env.yml:/etc/env.yml \
196+
-d osixia/openldap
197+
140198
## Manual build
141199

142200
Clone this project :
@@ -148,18 +206,18 @@ Adapt Makefile, set your image NAME and VERSION, for example :
148206

149207
NAME = osixia/openldap
150208
VERSION = 0.10.0
151-
209+
152210
becomes :
153211
NAME = billy-the-king/openldap
154212
VERSION = 0.1.0
155213

156214
Build your image :
157-
215+
158216
make build
159-
217+
160218
Run your image :
161219

162-
docker run -d billy-the-king/openldap:0.1.0
220+
docker run -h ldap.example.org -d billy-the-king/openldap:0.1.0
163221

164222
## Tests
165223

@@ -170,5 +228,3 @@ We use **Bats** (Bash Automated Testing System) to test this image:
170228
Install Bats, and in this project directory run :
171229

172230
make test
173-
174-

image/Dockerfile

Lines changed: 9 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
FROM osixia/baseimage:0.10.4
1+
FROM osixia/baseimage:0.10.5
22
MAINTAINER Bertrand Gouny <[email protected]>
33

44
# Use baseimage-docker's init system.
@@ -7,24 +7,21 @@ CMD ["/sbin/my_init"]
77
# Add openldap user and group first to make sure their IDs get assigned consistently, regardless of whatever dependencies get added
88
RUN groupadd -r openldap && useradd -r -g openldap openldap
99

10-
# Install OpenLDAP and ldap-utils (and ssl-kit from baseimage), remove default ldap db
10+
# Install OpenLDAP, ldap-utils and ssl-kit from baseimage, remove default ldap db
1111
RUN apt-get -y update && /sbin/enable-service ssl-kit \
12-
&& LC_ALL=C DEBIAN_FRONTEND=noninteractive apt-get install -y --force-yes --no-install-recommends slapd ldap-utils \
13-
&& rm -rf /var/lib/ldap
12+
&& LC_ALL=C DEBIAN_FRONTEND=noninteractive apt-get install -y --force-yes --no-install-recommends \
13+
slapd ldap-utils ntp \
14+
&& rm -rf /var/lib/ldap /etc/ldap/slapd.d
1415

15-
# Add OpenLDAP assets
16-
ADD service/slapd/assets /osixia/slapd
16+
# Add service directory to /osixia
17+
ADD service /osixia
1718

18-
# Clean all
19-
RUN apt-get clean && rm -rf /var/lib/apt/lists/* /tmp/* /var/tmp/*
19+
# Use baseimage service auto-install script and clean all
20+
RUN ./sbin/auto-install && apt-get clean && rm -rf /var/lib/apt/lists/* /tmp/* /var/tmp/*
2021

2122
# Add default env variables
2223
ADD env.yml /etc/env.yml
2324

24-
# Add OpenLDAP container start config & daemon
25-
ADD service/slapd/container-start.sh /etc/my_init.d/slapd
26-
ADD service/slapd/daemon.sh /etc/service/slapd/run
27-
2825
# Set OpenLDAP data and config directories in a data volume
2926
VOLUME ["/var/lib/ldap", "/etc/ldap/slapd.d"]
3027

image/env.yml

Lines changed: 17 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,26 @@
11
LDAP_ORGANISATION: Example Inc.
22
LDAP_DOMAIN: example.org
33
LDAP_ADMIN_PASSWORD: admin
4-
LDAP_LOG_LEVEL: -1
4+
LDAP_CONFIG_PASSWORD: config
55

6-
SERVER_NAME: ldap.example.org
6+
#See table 5.1 in http://www.openldap.org/doc/admin24/slapdconf2.html for the available log levels.
7+
LDAP_LOG_LEVEL: -1
78

89
USE_TLS: true
910
SSL_CRT_FILENAME: ldap.crt
1011
SSL_KEY_FILENAME: ldap.key
1112
SSL_CA_CRT_FILENAME: ca.crt
13+
14+
15+
USE_REPLICATION: false
16+
# variables $BASE_DN, $LDAP_ADMIN_PASSWORD, $LDAP_CONFIG_PASSWORD and $SSL_*
17+
# are automaticaly replaced at run time
18+
19+
# if you want to add replication to an existing ldap
20+
# adapt REPLICATION_CONFIG_SYNCPROV and REPLICATION_HDB_SYNCPROV to your configuration
21+
# avoid using $BASE_DN, $LDAP_ADMIN_PASSWORD and $LDAP_CONFIG_PASSWORD variables
22+
REPLICATION_CONFIG_SYNCPROV: binddn="cn=admin,cn=config" bindmethod=simple credentials=$LDAP_CONFIG_PASSWORD searchbase="cn=config" type=refreshAndPersist retry="5 5 300 5" timeout=1 starttls=critical
23+
REPLICATION_HDB_SYNCPROV: binddn="cn=admin,$BASE_DN" bindmethod=simple credentials=$LDAP_ADMIN_PASSWORD searchbase="$BASE_DN" type=refreshAndPersist interval=00:00:00:10 retry="5 5 300 5" timeout=1 starttls=critical
24+
REPLICATION_HOSTS:
25+
- ldap://ldap.example.org # The order must be the same on all ldap servers
26+
- ldap://ldap2.example.org

image/service/slapd/assets/config/README.md

Lines changed: 0 additions & 1 deletion
This file was deleted.
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
Bootstrap config, for a container started without an existing ldap config.
Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
# Set config password
2+
dn: cn=config
3+
changeType: modify
4+
5+
dn: olcDatabase={0}config,cn=config
6+
add: olcRootPW
7+
olcRootPW: {{ CONFIG_PASSWORD_ENCRYPTED }}
Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
# Add indexes
2+
dn: olcDatabase={1}hdb,cn=config
3+
changetype: modify
4+
replace: olcDbIndex
5+
olcDbIndex: entryCSN eq
6+
olcDbIndex: entryUUID eq

image/service/slapd/assets/config/logging.ldif renamed to image/service/slapd/assets/config/bootstrap/ldif/logging.ldif

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
11
dn: cn=config
22
changetype: modify
33
replace: olcLogLevel
4-
olcLogLevel: stats
4+
olcLogLevel: stats

0 commit comments

Comments
 (0)