docker部署gitlab
# 安装gitlab
[root@tiaoban gitlab]# docker pull gitlab/gitlab-ee
[root@tiaoban gitlab]# mkdir config logs data
[root@tiaoban gitlab]# ls
config data logs
[root@tiaoban gitlab]# pwd
/opt/gitlab
[root@tiaoban gitlab]# docker run --detach \
--hostname gitlab.local.com \
--publish 443:443 --publish 80:80 --publish 8022:22 \
--name gitlab \
--restart always \
--volume $PWD/config:/etc/gitlab \
--volume $PWD/logs:/var/log/gitlab \
--volume $PWD/data:/var/opt/gitlab \
--shm-size 256m \
gitlab/gitlab-ce:16.0.4-ce.0
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
# 修改配置文件
[root@tiaoban gitlab]# vim config/gitlab.rb
external_url 'http://gitlab.local.com'
gitlab_rails['gitlab_ssh_host'] = '192.168.10.100'
gitlab_rails['time_zone'] = 'Asia/Shanghai'
gitlab_rails['gitlab_shell_ssh_port'] = 8022
# 解决头像显示异常问题
gitlab_rails['gravatar_plain_url'] = 'http://sdn.geekzu.org/avatar/%{hash}?s=%{size}&d=identicon'
gitlab_rails['gravatar_ssl_url'] = 'https://sdn.geekzu.org/avatar/%{hash}?s=%{size}&d=identicon'
# 关闭 promethues和alertmanager
prometheus['enable'] = false
alertmanager['enable'] = false
# 默认gitlab配置资源占用较高,可以根据情况减少资源占用
# 关闭邮件服务
gitlab_rails['gitlab_email_enabled'] = false
gitlab_rails['smtp_enable'] = false
# 减少 postgresql 数据库缓存
postgresql['shared_buffers'] = "128MB"
# 减少 postgresql 数据库并发数量
postgresql['max_connections'] = 100
# nginx减少进程数
nginx['worker_processes'] = 2
[root@tiaoban gitlab]# docker exec -it gitlab bash
root@gitlab:/# gitlab-ctl reconfigure
gitlab Reconfigured!
root@gitlab:/# exit
exit
[root@tiaoban gitlab]# docker restart gitlab
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
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
docker-compose部署方式
version: '3.1'
services:
gitlab:
image: 'gitlab/gitlab-ce:latest'
container_name: gitlab
restart: always
environment:
GITLAB_OMNIBUS_CONFIG: |
external_url 'http://192.168.11.11:8929'
gitlab_rails['gitlab_shell_ssh_port'] = 2224
ports:
- '8929:8929'
- '2224:22'
volumes:
- './config:/etc/gitlab'
- './logs:/var/log/gitlab'
- './data:/var/opt/gitlab'
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
# 服务控制
[root@tiaoban gitlab]# docker restart gitlab
[root@tiaoban gitlab]# docker start gitlab
[root@tiaoban gitlab]# docker stop gitlab
[root@tiaoban gitlab]# docker rm gitlab
1
2
3
4
2
3
4
# 客户端添加hosts记录
修改hosts文件,添加如下记录gitlab.local.com 192.168.10.100,然后浏览器访问即可。
1
上次更新: 2024/04/25, 14:45:25