I'm new to Docker and I'm trying to do something with Docker Networking. I have two containers, one is GitLab, and the other OpenLDAP, and I hope that I can get my Gitlab server to be setup with OpenLDAP authentication. I have the two composes below. The Gitlab compose is mainly copy and paste, as I'm not actually 100% sure on what the settings are supposed to be for the environment variables in order to have it communicate internally with the OpenLDAP container. I was hoping they could communicate entirely internally through a user-defined bridge called "loworkNetwork" I started before starting these composes.
Gitlab Docker-Compose
version: '2'
services:
web:
image: 'gitlab/gitlab-ce:latest'
restart: always
hostname: 'gitlab'
environment:
GITLAB_OMNIBUS_CONFIG: |
external_url 'my_external_url'
# These settings are documented in more detail at
# https://gitlab.com/gitlab-org/gitlab-ce/blob/a0a826ebdcb783c660dd40d8cb217db28a9d4998/config/gitlab.yml.example#L136
gitlab_rails['ldap_enabled'] = true
gitlab_rails['ldap_host'] = 'ldap-service'
gitlab_rails['ldap_port'] = 389
gitlab_rails['ldap_uid'] = 'uid'
gitlab_rails['ldap_method'] = 'plain' # 'ssl' or 'plain'
gitlab_rails['ldap_bind_dn'] = 'cn=admin,dc=my_external_url,dc=com'
gitlab_rails['ldap_password'] = 'password'
gitlab_rails['ldap_allow_username_or_email_login'] = true
gitlab_rails['ldap_base'] = 'dc=my_external_url,dc=com'
ports:
- '80:80'
- '443:443'
- '22:22'
volumes:
- '/srv/gitlab/config:/etc/gitlab'
- '/srv/gitlab/logs:/var/log/gitlab'
- '/srv/gitlab/data:/var/opt/gitlab'
networks:
- loworkNetwork
networks:
loworkNetwork:
external: true
LDAP Services Docker-Compose
version: '2'
services:
openldap:
image: osixia/openldap:latest
environment:
- LDAP_ORGANISATION="lowork"
- LDAP_DOMAIN=my_external_url
- LDAP_ADMIN_PASSWORD=password
networks:
- loworkNetwork
hostname: ldap-service
phpldapadmin:
image: osixia/phpldapadmin:latest
ports:
- "8080:80"
environment:
- PHPLDAPADMIN_LDAP_HOSTS=openldap
- PHPLDAPADMIN_HTTPS=false
networks:
- loworkNetwork
networks:
loworkNetwork:
external: true
I've figured it out! In my case, all I had to do was change the host to the name of my container. So to in my gitlab docker-compose, I just changed the ldap-host to openldap because that's the name of my container.