尝试将 GitLab-CE docker 容器连接到 OpenLDAP docker 容器
Trying to connect GitLab-CE docker container to OpenLDAP docker container
我是 Docker 的新手,我正在尝试使用 Docker 网络做点什么。我有两个容器,一个是 GitLab,另一个是 OpenLDAP,我希望我可以使用 OpenLDAP 身份验证设置我的 Gitlab 服务器。我有下面的两个组合。 Gitlab compose 主要是复制和粘贴,因为我实际上并不是 100% 确定环境变量的设置应该是什么,以便让它与 OpenLDAP 容器进行内部通信。我希望他们可以通过一个名为 "loworkNetwork" 的用户定义的桥完全在内部进行通信,我在开始这些撰写之前就开始了。
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 服务 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
我想通了!就我而言,我所要做的就是将主机更改为我的容器的名称。所以在我的 gitlab docker-compose 中,我只是将 'ldap-host' 更改为 'openldap' 因为那是我的容器的名称。
我是 Docker 的新手,我正在尝试使用 Docker 网络做点什么。我有两个容器,一个是 GitLab,另一个是 OpenLDAP,我希望我可以使用 OpenLDAP 身份验证设置我的 Gitlab 服务器。我有下面的两个组合。 Gitlab compose 主要是复制和粘贴,因为我实际上并不是 100% 确定环境变量的设置应该是什么,以便让它与 OpenLDAP 容器进行内部通信。我希望他们可以通过一个名为 "loworkNetwork" 的用户定义的桥完全在内部进行通信,我在开始这些撰写之前就开始了。
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 服务 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
我想通了!就我而言,我所要做的就是将主机更改为我的容器的名称。所以在我的 gitlab docker-compose 中,我只是将 'ldap-host' 更改为 'openldap' 因为那是我的容器的名称。