Super detailed Docker Desktop installation GitLab

1. Introduction to GitLab

GitLab is divided into Community Edition ( Community Edition, abbreviated as CE) and Enterprise Edition ( Enterprise Edition, abbreviated as
EE). The community edition is free, while the enterprise edition includes some paid services. Generally speaking, the community edition is enough for individual developers.
GitLab is a code management tool based on git warehouse, which can help our team to perform version control and collaborative development. Gitlab also provides a complete continuous integration/continuous delivery platform, which can automate code construction, testing, release and other processes, and is an open source platform. Companies can also customize it according to their needs to meet different teams and adapt to different needs. and process.

gitlab official website: https://gitlab.cn/install/
gitlab official documentation: https://docs.gitlab.com/ee/install/docker.html
gitlab official documentation: https://docs.gitlab.cn/runner/ install/docker.html

insert image description here

2. Install GitLab using Docker Desktop

1. Install Docker Desktop

Please see here: Docker Desktop installation tutorial

Then if you want to install a Linux system first, please see here: Install Centos system using Docker Desktop

2. Use Docker Desktop to install the GitLab image

2.1. View GitLab mirror

GitLab CE Docker Image (Community Edition)
GitLab EE Docker Image (Enterprise Edition)

# 查询镜像
docker search gitlab

insert image description here
Use Docker Desktop to view the GitLab image

insert image description here

2.2. Download the GitLab image

insert image description here

# 拉取最新版本的镜像命令,不加 tag 则默认为最新版本 latest
docker pull gitlab/gitlab-ce
# 拉取最新版本的镜像命令
docker pull beginor/gitlab-ce:latest
# 拉取指定版本的镜像命令
docker pull gitlab/gitlab-ce:15.6.3-ce.0

insert image description here
insert image description here

Download the GitLab image using Docker Desktop:

insert image description here

insert image description here

Download the GitLab mirror using Linux:

insert image description here

2.3. Start service GitLab image

docker run --name gitlab --restart always -p 9980:9980 -p 222:22 -v /usr/local/docker/gitlab/config:/etc/gitlab -v /usr/local/docker/gitlab/logs:/var/log/gitlab -v /usr/local/docker/gitlab/data:/var/opt/gitlab -d gitlab/gitlab-ce

Here is an explanation of the situation of this string of codes. If you copy it, copy the above command

docker run
-d #Background operation, full name: detach
-p 8443:443 #Map the internal port of the container to the outside
-p 8090:80 #Map port 80 in the container to port 8090 of the host, which is the port for accessing gitlab
-p 8022:22 #Map port 22 in the container to port 8022 of the host, which is the port for accessing ssh
–restart always #Container self-start
–name gitlab #Set the container name to gitlab
-v /usr/local/gitlab/etc:/ etc/gitlab #Mount the container /etc/gitlab directory to the host /usr/local/gitlab/etc directory, if this directory does not exist in the host, it will be automatically created -v /usr/local/gitlab/log
: /var/log/gitlab #Same as above
-v /usr/local/gitlab/data:/var/opt/gitlab #Same as above
–privileged=true #Let the container obtain the root permission of the host twang2218/gitlab-ce-zh #The name of the image, you can also write the image ID here

insert image description here

Start the GitLab image using Docker Desktop:

insert image description here

Start the GitLab mirror with Linux:

insert image description here

2.4. Check whether Gitlab has started

# 添加-a 参数,把启动的,没有启动的都列出来
docker ps

insert image description here

2.5. View the running status of Gitlab

# 查看Gitlab的运行状态
docker logs -f gitlab

Waiting for execution, the startup time may be relatively long, and finally stop scrolling, and find that the system executes without reporting an error, and the system is running normally. Use the ctrl + c key combination to exit.

insert image description here

3. Configure Gitlab

3.1. Modify 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 bash

insert image description here

#修改gitlab.rb
vi /etc/gitlab/gitlab.rb

insert image description here
insert image description here

# 编辑
insert 
# 搜索
/搜索内容(如:/external_url )   
# 下一个搜索内容
N	

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

# 操作
Esc    
# 保存退出
:wq 
# 直接退出
:q! 

insert image description here

insert image description here
Or just put the configuration together:

insert image description here


# 重新编译gitlab配置文件
gitlab-ctl reconfigure

insert image description here

# 重启gitlab服务
gitlab-ctl restart

insert image description here

#退出容器
exit

insert image description here

# 重启gitlab容器
docker restart gitlab

insert image description here

3.2. Visit gitlab page 502

Visit http:ip:8929 in your browser and replace ip with the ip address of your server.

insert image description here
Visit the gitlab page 502 solution:

The editing command is the same as above, so I won’t write it in detail here

①修改/etc/gitlab/gitlab.rb(2个参数对应的端口一致)  
unicorn['port'] = 8888
gitlab_workhorse['auth_backend'] = "http://localhost:8888" 

②重新执行配置
gitlab-ctl reconfigure
gitlab-ctl restart

insert image description here
insert image description here
insert image description here

3.3. Access to gitlab

# 进入并查看一下初始密码
docker exec -it gitlab cat /etc/gitlab/initial_root_password

insert image description here
Then visit http:ip:8929 in the browser (replace ip with the ip address of your server), click Sign in, and find that you can log in normally.

insert image description here
insert image description here

3.4. Modify password

Find the password button according to the picture, and change the password.
insert image description here

After entering the old password and then the new password twice, click Save password. And that's it!

insert image description here

3.5. Close the registration function

I don't use the registration function here, so I turned off the registration function.

insert image description here
insert image description here

Finally click save changes to save the application.

insert image description here

4. Operations on the Gitlab page

For details, please check here: Gitlab add group, create user and project, permission management

5. Firewall open ports

If external access is not available, you can check whether the firewall is not open

#查看防火墙状态
systemctl status firewalld  

#开启防火墙
systemctl start firewalld   

#关闭防火墙  
systemctl stop firewalld    

 #查看开放端口
firewall-cmd --list-ports    

#设置80800端口开放
firewall-cmd --zone=public --add-port=8080/tcp --permanent 

#再次查看是否开放
firewall-cmd --list-ports     

Guess you like

Origin blog.csdn.net/GoodburghCottage/article/details/131683475