1. gitlab环境准备
1.1 拉取镜像
docker pull gitlab/gitlab-ce:12.10.0-ce.0
1.2 准备挂载目录
mkdir -p /mydata/gitlab/config
mkdir -p /mydata/gitlab/logs
mkdir -p /mydata/gitlab/data
1.3 运行镜像
docker run --detach \
--restart=always \
--hostname 172.16.25.69 \
--publish 9443:443 --publish 99:99 --publish 9022:22 \
--name gitlab --restart always \
--volume /mydata/gitlab/config:/etc/gitlab \
--volume /mydata/gitlab/logs:/var/log/gitlab \
--volume /mydata/gitlab/data:/var/opt/gitlab \
gitlab/gitlab-ce:12.10.0-ce.0
1.4 修改gitlab.rb 配置文件
按上面的安装方式运行没问题,但是在gitlab上创建项目的时候,生成的项目url访问地址是按照容器的hostname来生成的,也就是容器id。作为gitlab服务器,我们需要固定一个ip地址或者域名。于是需要配置gitlab.rb(宿主机路径:/mydata/gitlab/config/gitlab.rb)配置有三个参数如:
external_url 'http://172.16.25.69:99'
gitlab_rails['gitlab_ssh_host'] = '172.16.25.69'
gitlab_rails['gitlab_shell_ssh_port'] = 9022
gitlab_rails['time_zone'] = 'Asia/Shanghai'
## gitlab配置邮箱
gitlab_rails['smtp_enable'] = true
gitlab_rails['smtp_address'] = "smtp.qq.com"
gitlab_rails['smtp_port'] = 465
gitlab_rails['smtp_user_name'] = "1046242635@qq.com"
gitlab_rails['smtp_password'] = "cemrtstvycmzbahg"
gitlab_rails['smtp_domain'] = "qq.com"
gitlab_rails['smtp_authentication'] = "login"
gitlab_rails['smtp_enable_starttls_auto'] = true
gitlab_rails['smtp_tls'] = true
user['git_user_email'] = "1046242635@qq.com"
gitlab_rails['gitlab_email_from'] = '1046242635@qq.com'
gitlab_rails['gitlab_email_display_name'] = 'liyu_gitlab_emall'
## 解决gitlab 暂用cpu,内存过大问题 TODO 重装了三次得出的结论
unicorn['worker_processes'] = 2
unicorn['worker_memory_limit_min'] = "100 * 1 << 20"
unicorn['worker_memory_limit_max'] = "250 * 1 << 20"
sidekiq['concurrency'] = 8
postgresql['shared_buffers'] = "128MB"
postgresql['max_worker_processes'] = 4
prometheus_monitoring['enable'] = false
1.5进入容器内部重启配置服务
docker exec -it gitlab /bin/bash
gitlab-ctl reconfigure
1.6 重启配置后,重新启动容器
docker restart gitlab
1.7 再查看本机端口状态
netstat -tnl