尝试将GitLab-CE docker容器连接到OpenLDAP docker容器

时间:2018-06-26 02:01:44

标签: docker docker-compose gitlab openldap

我是Docker的新手,我正在尝试使用Docker Networking做一些事情。我有两个容器,一个是GitLab,另一个是OpenLDAP,我希望我可以使用OpenLDAP身份验证来设置我的Gitlab服务器。我有下面的两个组成部分。 Gitlab的编写主要是复制和粘贴,因为我实际上不是100%确信应该为环境变量设置什么以使其与OpenLDAP容器进行内部通信。我希望他们能够通过一个我定义的用户定义的网桥完全内部地进行通信,该网桥是在我开始撰写这些文件之前启动的。

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

1 个答案:

答案 0 :(得分:1)

我知道了!就我而言,我所要做的就是将主机更改为容器的名称。所以在gitlab docker-compose中,我只是将'ldap-host'更改为'openldap',因为那是我的容器的名称。