Docker deploys Gitlab server (detailed steps)

Table of contents

        Gitlab mirror

1. Pull the Gitlab image

2. Start the Gitlab container 

3. Modify the configuration

4. Browser access 

5. Modify the root password

6. gitlab operation


Gitlab mirror


1. Pull the Gitlab image

docker pull gitlab/gitlab-ce:latest


 2. Start the Gitlab container 

docker run \
 -itd  \
 -p 9980:80 \
 -p 9922:22 \
 -v /home/gitlab/etc:/etc/gitlab  \
 -v /home/gitlab/log:/var/log/gitlab \
 -v /home/gitlab/opt:/var/opt/gitlab \
 --restart always \
 --privileged=true \
 --name gitlab \
 gitlab/gitlab-ce

# 查看docker启动
docker ps


3. Modify the configuration

Please modify the following configurations in the container, not on the files mounted to the host. Otherwise, the configuration may not be updated in the container, or cannot be updated in the container immediately, resulting in successful startup of gitlab, but inaccessible

#进入容器内部
docker exec -it gitlab /bin/bash

#修改gitlab.rb
vi /etc/gitlab/gitlab.rb
 
#加入如下
#gitlab访问地址,可以写域名。如果端口不写的话默认为80端口
external_url 'http://192.168.249.132' 
#ssh主机ip
gitlab_rails['gitlab_ssh_host'] = '192.168.249.132'
#ssh连接端口
gitlab_rails['gitlab_shell_ssh_port'] = 9922

After the modification is completed, save and exit. Since we are running in docker , the http address generated on gitlab should be http://192.168.249.132:9980, so the following files need to be modified

# 修改http和ssh配置
vi /opt/gitlab/embedded/service/gitlab-rails/config/gitlab.yml
 
  gitlab:
    host: 192.168.249.132
    port: 9980 # 这里改为9980
    https: false

 After the modification is complete, save and exit, and restart gitlab

#重启gitlab 
gitlab-ctl restart
#退出容器 
exit


4. Browser access 

Path access: http://192.168.249.132:9980/

The machine configuration must be greater than 4g, otherwise it will easily fail to start and report 502

 (Wait a little longer, refresh a little more)

For the first visit, you will be asked to modify the root password.
After modification, you can log in as the root user. 

 

 


5. Modify the root password

# 进入容器内部
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
 

Just log in:

Username: root

Password: the password just changed


6. gitlab operation

create project

 

 

 docker deployment gitlab completed! ! !

Guess you like

Origin blog.csdn.net/weixin_53443677/article/details/125518696