gitlab on docker

1、环境

Linux debian12 6.1.0-13-amd64 #1 SMP PREEMPT_DYNAMIC Debian 6.1.55-1 (2023-09-29) x86_64 GNU/Linux
Docker version 20.10.24+dfsg1, build 297e128
gitlab-ce:16.5.3

2、部署

docker run -d -p 443:443 -p 2222:22 -p 80:80 \
  --hostname gitlab.gaojinbo.com \
  --name gitlab --restart always \
  -v /data/gitlab/etc:/etc/gitlab \
  -v /data/gitlab/log:/var/log/gitlab \
  -v /data/gitlab/data:/var/opt/gitlab \
  --shm-size 256m gitlab/gitlab-ce:16.5.3-ce.0

3、配置

获取root密码

docker exec -it gitlab.gaojinbo.com grep 'Password:' /etc/gitlab/initial_root_password

配置ssl证书

vi /data/gitlab/etc/gitlab.rb
external_url 'https://gitlab.gaojinbo.com'
gitlab_rails['gitlab_ssh_host'] = 'gitlab.gaojinbo.com'
gitlab_rails['time_zone'] = 'Asia/Shanghai'
gitlab_rails['gitlab_shell_ssh_port'] = 2222
gitlab_rails['smtp_enable'] = true
gitlab_rails['smtp_address'] = "smtp.exmail.qq.com"
gitlab_rails['smtp_port'] = 465
gitlab_rails['smtp_user_name'] = "gitlab@gaojinbo.com"
gitlab_rails['smtp_password'] = "$$ PASSWD $$"
gitlab_rails['smtp_domain'] = "exmail.qq.com"
gitlab_rails['smtp_authentication'] = "login"
gitlab_rails['smtp_enable_starttls_auto'] = true
gitlab_rails['smtp_tls'] = true
gitlab_rails['gitlab_email_from'] = 'gitlab@gaojinbo.com'
nginx['redirect_http_to_https'] = true
nginx['ssl_certificate'] = "/etc/gitlab/gitlab.gaojinbo.com.pem"
nginx['ssl_certificate_key'] = "/etc/gitlab/gitlab.gaojinbo.com.key"

docker exec -it gitlab.gaojinbo.com gitlab-ctl reconfigure