Skip to content

Commit 31c552f

Browse files
committed
Update README.md
1 parent 1283a3b commit 31c552f

File tree

1 file changed

+157
-3
lines changed

1 file changed

+157
-3
lines changed

README.md

Lines changed: 157 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,162 @@
1-
# docker-openldap
1+
# osixia/openldap
2+
3+
A docker image to run OpenLDAP.
4+
> [www.openldap.org](http://www.openldap.org/)
25
36
Fork of Nick Stenning docker-slapd :
47
https://github.com/nickstenning/docker-slapd
58

6-
Add support of tls.
9+
Add support of tls. Use docker 1.5.0
10+
11+
## Quick start
12+
Run OpenLDAP docker image :
13+
14+
docker run -d osixia/openldap
15+
16+
This start a new container with a OpenLDAP server running inside.
17+
The odd string printed by this command is the `CONTAINER_ID`.
18+
We are going to use this `CONTAINER_ID` to execute some commands inside the container.
19+
20+
Wait 1 or 2 minutes the container startup to be completed.
21+
22+
Then run a terminal on this container,
23+
make sure to replace `CONTAINER_ID` by your container id :
24+
25+
docker exec -it CONTAINER_ID bash
26+
27+
You should now be in the container terminal,
28+
and we can search on the ldap server :
29+
30+
ldapsearch -x -h 127.0.0.1 -b dc=example,dc=org
31+
32+
This should output :
33+
34+
# extended LDIF
35+
#
36+
# LDAPv3
37+
# base <dc=example,dc=org> with scope subtree
38+
# filter: (objectclass=*)
39+
# requesting: ALL
40+
#
41+
42+
[...]
43+
44+
# numResponses: 3
45+
# numEntries: 2
46+
47+
if you have the following error, OpenLDAP is not started yet, wait some time.
48+
49+
ldap_sasl_bind(SIMPLE): Can't contact LDAP server (-1)
50+
51+
52+
## Examples
53+
54+
### Create new ldap server
55+
56+
This is the default behaviour when you run the image.
57+
It will create an empty ldap for the compagny **Example Inc.** and the domain **example.org**.
58+
59+
By default the admin has the password **admin**. All those default settings can be changed at the docker command line, for example :
60+
61+
docker run -e LDAP_ORGANISATION="My Compagny" -e LDAP_DOMAIN="my-compagny.com" \
62+
-e LDAP_ADMIN_PASSWORD="JonSn0w" -d osixia/openldap
63+
64+
#### Data persitance
65+
66+
The directories `/var/lib/ldap` (LDAP database files) and `/etc/ldap/slapd.d` (LDAP config files) has been declared as volumes, so your ldap files are saved outside the container in data volumes.
67+
68+
This mean that you can stop, and restart the container and get back your ldap without losing any data. But if you remove the container, data volumes will me removed too, except if you have linked this data volume to an other container.
69+
70+
For more information about docker data volume, please refer to :
71+
72+
> [https://docs.docker.com/userguide/dockervolumes/](https://docs.docker.com/userguide/dockervolumes/)
73+
74+
75+
### Use an existing ldap database
76+
77+
This can be achieved by mounting host directories as volume.
78+
Assuming you have a LDAP database on your docker host in the directory `/data/slapd/database`
79+
and the corresponding LDAP config files on your docker host in the directory `/data/slapd/config`
80+
simply mount this directories as a volume to `/var/lib/ldap` and `/etc/ldap/slapd.d`:
81+
82+
docker run -v /data/slapd/database:/var/lib/ldap \
83+
-v /data/slapd/config:/etc/ldap/slapd.d
84+
-d osixia/openldap
85+
86+
### Using TLS
87+
88+
#### Use autogenerated certificate
89+
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+
91+
docker run -e SERVER_NAME=ldap.my-compagny.com -d osixia/openldap
92+
93+
#### Use your own certificate
94+
95+
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)).
96+
97+
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+
99+
docker run -v /path/to/certifates:/osixia/slapd/ssl \
100+
-e SSL_CRT_FILENAME=my-ldap.crt \
101+
-e SSL_KEY_FILENAME=my-ldap.key \
102+
-e SSL_CA_CRT_FILENAME=the-ca.crt \
103+
-d osixia/mariadb
104+
105+
## Environment Variables
106+
107+
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.
108+
109+
Required for new ldap server :
110+
- **LDAP_ORGANISATION**: Organisation name. Defaults to `Example Inc.`
111+
- **LDAP_DOMAIN**: Ldap domain. Defaults to `example.org`
112+
- **LDAP_ADMIN_PASSWORD** Admin password. Defaults to `admin`
113+
114+
TLS options :
115+
- **USE_TLS**: Add openldap TLS capabilities. Defaults to `true`
116+
- **SSL_CRT_FILENAME**: Ldap ssl certificate filename. Defaults to `ldap.crt`
117+
- **SSL_KEY_FILENAME**: Ldap ssl certificate private key filename. Defaults to `ldap.key`
118+
- **SSL_CA_CRT_FILENAME**: Ldap ssl CA certificate filename. Defaults to `ca.crt`
119+
- **SERVER_NAME**: Use by autogenerated certificate: Server CN. Defaults to `ldap.example.org`
120+
121+
### Set environment variables at run time :
122+
123+
Environment variable can be set directly by adding the -e argument in the command line, for example :
124+
125+
docker run -e LDAP_ORGANISATION="My Compagny" -e LDAP_DOMAIN="my-compagny.com" \
126+
-e LDAP_ADMIN_PASSWORD="JonSn0w" -d osixia/openldap
127+
128+
## Manual build
129+
130+
Clone this project :
131+
132+
git clone https://github.com/osixia/docker-openldap
133+
cd docker-mariadb
134+
135+
Adapt Makefile, set your image NAME and VERSION, for example :
136+
137+
NAME = osixia/openldap
138+
VERSION = 0.10.0
139+
140+
becomes :
141+
NAME = billy-the-king/openldap
142+
VERSION = 0.1.0
143+
144+
Build your image :
145+
146+
make build
147+
148+
Run your image :
149+
150+
docker run -d billy-the-king/openldap:0.1.0
151+
152+
## Tests
153+
154+
We use **Bats** (Bash Automated Testing System) to test this image:
155+
156+
> [https://github.com/sstephenson/bats](https://github.com/sstephenson/bats)
157+
158+
Install Bats, and in this project directory run :
159+
160+
make test
7161

8-
Use docker 1.5.0
162+

0 commit comments

Comments
 (0)