1、拉取镜像文件
docker pull gitlab/gitlab-ce:14.1.0-ce.0
2、启动容器
docker run --restart=always -p 1443:443 -p 18080:18080 --name mygitlab-ce -v ~/gitlab/gitlab-config:/etc/gitlab -v ~/gitlab/gitlab-log:/var/log/gitlab -v ~/gitlab/gitlab-data:/var/opt/gitlab -d gitlab/gitlab-ce:14.1.0-ce.0
3、配置Gitlab地址
vi ~/gitlab/gitlab-config/gitlab.rb ;修改文件中external_url信息 external_url "http://IP:18080" ;重启Gitlab docker restart mygitlab-ce ;查看Log,等待重启完成 docker logs -f gitlab-ce
4、获取Root密码
;进入容器 docker exec -it mygitlab-ce bash # 执行下面命令启动一个 Ruby on Rails console,等待 console加载完成 root@44b33d22e70f:/# gitlab-rails console -e production ------------------------------------------------------------------------------------- GitLab: 11.1.4 (63daf37) GitLab Shell: 7.1.4 postgresql: 9.6.8 ------------------------------------------------------------------------------------- Loading production environment (Rails 4.2.10) irb(main):001:0> user = User.where(id: 1).first => #<User id:1 @root> irb(main):002:0> user.password="12345678" #设置密码 => "12345678" irb(main):003:0> user.password_confirmation="12345678" #确认密码 => "12345678" irb(main):004:0> user.save! # 保存修改 Enqueued ActionMailer::DeliveryJob (Job ID: 38850b0d-7690-47b7-b5c9-9cf975bae8fd) to Sidekiq(mailers) with arguments: "DeviseMailer", "password_change", "deliver_now", gid://gitlab/User/1 => true irb(main):005:0> quit #退出 Ruby on Rails console
5、恢复备份数据(可跳过)
1. 修改这个文件 vi /var/opt/gitlab/postgresql/data/postgresql.conf 找到listen_addresses = ” 改为listen_addresses = ‘*’ 2. 修改vi /var/opt/gitlab/postgresql/data/pg_hba.conf 在这个文件最后面加入 local all all trust host all all 127.0.0.1/32 trust host all all ::1/128 trust 3. 重启gitlab生效 gitlab-ctl restart 4. 进入postgresql命令行 cd /opt/gitlab/embedded/bin su gitlab-psql ./psql -h 127.0.0.1 gitlabhq_production 5. 执行修改gitlab用户为超级权限 ALTER USER gitlab WITH SUPERUSER; 退出 q 6.停止一下服务 gitlab-ctl stop unicorn gitlab-ctl stop sidekiq 7.修改备份文件及备份目录权限 chown -R git:git /var/opt/gitlab/backups/1629939755_2021_08_26_14.1.0_gitlab_backup.tar chown -R git:git /var/opt/gitlab/backups 8.恢复备份 gitlab-rake gitlab:backup:restore BACKUP=1629939755_2021_08_26_14.1.0 9.重启服务 sudo gitlab-ctl start
6、重启容器
docker restart mygitlab-ce