docker-compose在本地快速拉起测试环境
# 前言
你可以通过 docker-compose 在本地快速拉起进行体验。
快速拉起的容器包括:
- MySQL-8.3
- openLDAP-1.4.0
- phpldapadmin-0.9.0
- go-ldap-admin-server
# 端口列表
服务端口映射如下:
Service | Port (宿主机端口:容器端口) |
---|---|
MySQL | 3306:3306 |
openLDAP | 389:389 |
phpldapadmin | 8091:80 |
go-ldap-admin | 8888:8888 |
拉起之前确认是否有与本地端口冲突的情况。
# 使用 sqlite 存储数据
在你合适的目录中创建 go-ldap-admin
文件夹,然后创建 docker-compose.yaml
文件,内容如下:
version: '3'
networks:
go-ldap-admin:
driver: bridge
services:
go-ldap-admin:
image: registry.cn-hangzhou.aliyuncs.com/eryajf/go-ldap-admin
container_name: go-ldap-admin
hostname: go-ldap-admin
restart: always
environment:
WAIT_HOSTS: openldap:389
DB_DRIVER: sqlite3
ports:
- 8888:8888
volumes:
- ./data/go-ldap-admin:/app/data
depends_on:
- openldap
links:
- openldap:go-ldap-admin-openldap
networks:
- go-ldap-admin
openldap:
image: registry.cn-hangzhou.aliyuncs.com/eryajf/openldap:1.4.1
container_name: go-ldap-admin-openldap
hostname: go-ldap-admin-openldap
restart: always
environment:
TZ: Asia/Shanghai
LDAP_ORGANISATION: "eryajf.net"
LDAP_DOMAIN: "eryajf.net"
LDAP_ADMIN_PASSWORD: "123456"
command: [ '--copy-service' ]
volumes:
- ./data/openldap/database:/var/lib/ldap
- ./data/openldap/config:/etc/ldap/slapd.d
ports:
- 389:389
networks:
- go-ldap-admin
phpldapadmin:
image: registry.cn-hangzhou.aliyuncs.com/eryajf/phpldapadmin:0.9.0
container_name: go-ldap-admin-phpldapadmin
hostname: go-ldap-admin-phpldapadmin
restart: always
environment:
TZ: Asia/Shanghai
PHPLDAPADMIN_HTTPS: "false"
PHPLDAPADMIN_LDAP_HOSTS: go-ldap-admin-openldap
ports:
- 8091:80
volumes:
- ./data/phpadmin:/var/www/phpldapadmin
depends_on:
- openldap
links:
- openldap:go-ldap-admin-openldap
networks:
- go-ldap-admin
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
执行如下命令使容器后台启动:
$ docker-compose up -d
1
应用启动之后,默认会创建对应的初始化数据,通过日志可以查看数据是否正常初始化,如果没有正常初始化,则下边的登陆可能无法正常进行。
当看到容器都正常运行之后,可以在本地进行访问:http://localhost:8888,用户名 / 密码: admin
/ 123456
如果想要访问 PhpLdapAdmin,则可访问:http://localhost:8091,用户名 / 密码: cn=admin,dc=eryajf,dc=net
/ 123456
如果并非通过 localhost 本机部署,则使用对应主机的 IP 加端口进行访问即可,例如你部署在 192.168.10.10 这台主机,则前端访问地址应该为:http://192.168.10.10:8888
# 使用 MySQL 存储数据
# docker-compose 集成 MySQL
在你合适的目录中创建 go-ldap-admin
文件夹,然后创建 docker-compose.yaml
文件,内容如下:
version: '3'
networks:
go-ldap-admin:
driver: bridge
services:
go-ldap-admin:
image: registry.cn-hangzhou.aliyuncs.com/eryajf/go-ldap-admin
container_name: go-ldap-admin
hostname: go-ldap-admin
restart: always
environment:
WAIT_HOSTS: mysql:3306, openldap:389
ports:
- 8888:8888
volumes:
- ./data/go-ldap-admin:/app/data
depends_on:
- mysql
- openldap
links:
- mysql:go-ldap-admin-mysql
- openldap:go-ldap-admin-openldap
networks:
- go-ldap-admin
mysql:
image: registry.cn-hangzhou.aliyuncs.com/eryajf/mysql:8.3
container_name: go-ldap-admin-mysql
hostname: go-ldap-admin-mysql
restart: always
ports:
- '3306:3306'
environment:
TZ: Asia/Shanghai
MYSQL_ROOT_PASSWORD: 123456
MYSQL_ROOT_HOST: "%"
MYSQL_DATABASE: go_ldap_admin
volumes:
- ./data/mysql:/var/lib/mysql
networks:
- go-ldap-admin
openldap:
image: registry.cn-hangzhou.aliyuncs.com/eryajf/openldap:1.4.1
container_name: go-ldap-admin-openldap
hostname: go-ldap-admin-openldap
restart: always
environment:
TZ: Asia/Shanghai
LDAP_ORGANISATION: "eryajf.net"
LDAP_DOMAIN: "eryajf.net"
LDAP_ADMIN_PASSWORD: "123456"
command: [ '--copy-service' ]
volumes:
- ./data/openldap/database:/var/lib/ldap
- ./data/openldap/config:/etc/ldap/slapd.d
ports:
- 389:389
networks:
- go-ldap-admin
phpldapadmin:
image: registry.cn-hangzhou.aliyuncs.com/eryajf/phpldapadmin:0.9.0
container_name: go-ldap-admin-phpldapadmin
hostname: go-ldap-admin-phpldapadmin
restart: always
environment:
TZ: Asia/Shanghai
PHPLDAPADMIN_HTTPS: "false"
PHPLDAPADMIN_LDAP_HOSTS: go-ldap-admin-openldap
ports:
- 8091:80
volumes:
- ./data/phpadmin:/var/www/phpldapadmin
depends_on:
- openldap
links:
- openldap:go-ldap-admin-openldap
networks:
- go-ldap-admin
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
# 使用外置 MySQL
在你合适的目录中创建 go-ldap-admin
文件夹,然后创建 docker-compose.yaml
文件,内容如下:
📢 注意
:需提前创建数据库及用户,并修改如下配置信息,注意 go-ldap-admin 容器要能够连上MYSQL_HOST
。
version: '3'
networks:
go-ldap-admin:
driver: bridge
services:
go-ldap-admin:
image: registry.cn-hangzhou.aliyuncs.com/eryajf/go-ldap-admin
container_name: go-ldap-admin
hostname: go-ldap-admin
restart: always
environment:
WAIT_HOSTS: openldap:389
DB_DRIVER: mysql
# 请修改下面的 MySql 配置,需自行创建数据库和用户
MYSQL_HOST: example
MYSQL_PORT: 3306
MYSQL_USERNAME: root
MYSQL_PASSWORD: 123456
MYSQL_DATABASE: go_ldap_admin
ports:
- 8888:8888
volumes:
- ./data/go-ldap-admin:/app/data
depends_on:
- openldap
links:
- openldap:go-ldap-admin-openldap
networks:
- go-ldap-admin
openldap:
image: registry.cn-hangzhou.aliyuncs.com/eryajf/openldap:1.4.1
container_name: go-ldap-admin-openldap
hostname: go-ldap-admin-openldap
restart: always
environment:
TZ: Asia/Shanghai
LDAP_ORGANISATION: "eryajf.net"
LDAP_DOMAIN: "eryajf.net"
LDAP_ADMIN_PASSWORD: "123456"
command: [ '--copy-service' ]
volumes:
- ./data/openldap/database:/var/lib/ldap
- ./data/openldap/config:/etc/ldap/slapd.d
ports:
- 389:389
networks:
- go-ldap-admin
phpldapadmin:
image: registry.cn-hangzhou.aliyuncs.com/eryajf/phpldapadmin:0.9.0
container_name: go-ldap-admin-phpldapadmin
hostname: go-ldap-admin-phpldapadmin
restart: always
environment:
TZ: Asia/Shanghai
PHPLDAPADMIN_HTTPS: "false"
PHPLDAPADMIN_LDAP_HOSTS: go-ldap-admin-openldap
ports:
- 8091:80
volumes:
- ./data/phpadmin:/var/www/phpldapadmin
depends_on:
- openldap
links:
- openldap:go-ldap-admin-openldap
networks:
- go-ldap-admin
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
配置之后启动命令及访问方式同上。
帮助我们改善此页面 (opens new window)
上次更新: 2024/04/16, 22:13:05