docker-compose部署安装gitlab
南江烂柯人 JAVA劝退师

拉取镜像

docker pull gitlab/gitlab-ce:nightly

编写docker-compose.yml

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
version: '3.5'
services:
gitlab:
# 镜像名
image: gitlab/gitlab-ce:nightly
# 容器名
container_name: test-gitlab
# 重启策略
restart: unless-stopped
privileged: true
environment:
TZ: 'Asia/Shanghai'
GITLAB_OMNIBUS_CONFIG: |
# #gitlab访问地址,可以写域名。如果端口不写的话默认为80端口
external_url 'http://labs.test.com:2333'
# #ssh主机ip
gitlab_rails['gitlab_shell_ssh_port'] = 1022
gitlab_rails['time_zone'] = 'Asia/Shanghai'
# 头像图片处理
#gitlab_rails['gravatar_plain_url'] = 'http://sdn.geekzu.org/avatar/%{hash}?s=%{size}&d=identicon'
gitlab_rails['gravatar_ssl_url'] = 'https://seccdn.libravatar.org/avatar/%{hash}?s=%{size}&d=identicon'
gitlab_rails['backup_path'] = "/var/opt/gitlab/backups"
# 是否开启nginx代理 此处必须true
nginx['enable'] = true
# https配置根据实际需求来配置, 如果是转发的https则可以不配置
nginx['redirect_http_to_https'] = false
nginx['ssl_prefer_server_ciphers'] = "off"
#nginx['ssl_certificate'] = "/etc/gitlab/ssl/labs.test.com.pem"
#nginx['ssl_certificate_key'] = "/etc/gitlab/ssl/labs.test.com.key"
# 端口映射
ports:
- 2333:2333 # 此处端口号须与 external_url 中保持一致,左边和右边都要一样
- 443:443
- 1022:22 # 这里的1022和上面的1022一致,但是右边必须是22,不能是其他
volumes:
- /home/gitlab/config:/etc/gitlab
- /home/gitlab/logs:/var/log/gitlab
- /home/gitlab/data:/var/opt/gitlab
- /home/gitlab/backups:/var/opt/gitlab/backups
# 该目录下面有初始密码
- /home/gitlab/etc:/etc/gitlab
networks:
default:
external: true
name: test

修改root密码

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
# 进入容器内部
docker exec -it gitlab /bin/bash

# 进入控制台
gitlab-rails console -e production

# 查询id为1的用户,id为1的用户是超级管理员
user = User.where(id:1).first
# 修改密码为pdl123456
user.password='pdl123456'
# 保存
user.save!
# 退出
exit

问题

初始密码

1
在/etc/gitlab目录下面int_password

#日志报错Failed to get final advertise address: No private IP address found, and explicit IP not provided

在 /etc/gitlab/gitlab.rb文件末尾追加配置

1
2
3
   alertmanager['flags'] = {
'cluster.advertise-address' => "127.0.0.1:9093",
}
  • 本文标题:docker-compose部署安装gitlab
  • 本文作者:南江烂柯人
  • 创建时间:2023-06-28 10:27:01
  • 本文链接:https://www.mattjia.com/2023/06/28/installation/docker-compose部署安装gitlab/
  • 版权声明:本博客所有文章除特别声明外,均采用 BY-NC-SA 许可协议。转载请注明出处!
 评论