官方文档入口
运行gitlab
1
2
3
4
5
6
7
8
9
10
11
| sudo docker run --detach \
--hostname gitlab.mkl.io \
--publish 880:80 --publish 22:22 \
--name gitlab \
--restart always \
--env TZ='Asia/Shanghai' \
--volume /srv/gitlab/config:/etc/gitlab \
--volume /srv/gitlab/logs:/var/log/gitlab \
--volume /srv/gitlab/data:/var/opt/gitlab \
--shm-size 256m \
gitlab/gitlab-ce
|
gitlab14版本开始,查看用户root的密码,14以前的版本在第一次访问gitlab时会要求设置root密码
1
| sudo docker exec gitlab grep 'Password:' /etc/gitlab/initial_root_password
|
配置smtp
https://docs.gitlab.com/omnibus/settings/smtp.html#smtp-settings
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
| sudo tee -a /srv/gitlab/config/gitlab.rb << EOF
gitlab_rails['smtp_enable'] = true
gitlab_rails['smtp_address'] = "smtp.exmail.qq.com"
gitlab_rails['smtp_port'] = 465
gitlab_rails['smtp_user_name'] = "[email protected]"
gitlab_rails['smtp_password'] = "123456"
gitlab_rails['smtp_authentication'] = "login"
gitlab_rails['smtp_enable_starttls_auto'] = true
gitlab_rails['smtp_tls'] = true
gitlab_rails['gitlab_email_from'] = '[email protected]'
gitlab_rails['smtp_domain'] = "exmail.qq.com"
EOF
sudo docker exec gitlab gitlab-ctl reconfigure
sudo docker exec gitlab gitlab-ctl restart
|
自动备份gitlab
1
2
3
4
5
6
7
| #每天凌晨3点备份
echo '0 3 * * * root /usr/bin/docker exec gitlab gitlab-backup create CRON=1' | sudo tee /etc/cron.d/gitlabbackup
#保留3天
echo "gitlab_rails['backup_keep_time'] = 259200" | sudo tee -a /srv/gitlab/config/gitlab.rb # 3天,259200秒
sudo docker exec gitlab gitlab-ctl reconfigure
sudo docker exec gitlab gitlab-ctl restart
|