[Continuous Integration CI/Continuous Deployment CD] 3. Install GitLab with Docker

1. Pull the gitlab image. gitlab-ce is a stable version. If you do not fill in the version later, the latest version will be pulled by default.

$ docker pull gitlab/gitlab-ce

2. Run the gitlab image

$ docker run -d  -p 443:443 -p 80:80 -p 222:22 --name gitlab --restart always -v /data/gitlab/config:/etc/gitlab -v /data/gitlab/logs:/var/log/gitlab -v /data/gitlab/data:/var/opt/gitlab gitlab/gitlab-ce

3. According to the above method, the gitlab container runs fine, but when creating a project on gitlab, the URL access address of the generated project is generated according to the hostname of the container, which is the id of the container. As a gitlab server, we need a fixed URL access address, so we need to configure gitlab.rb (host path: /data/gitlab/config/gitlab.rb), and the content of gitlab.rb file is full of comments by default:

# gitlab.rb文件内容默认全是注释
$ vi /data/gitlab/config/gitlab.rb

# 配置http协议所使用的访问地址,不加端口号默认为80
external_url 'http://192.168.10.106'

# 配置ssh协议所使用的访问地址和端口
gitlab_rails['gitlab_ssh_host'] = '192.168.10.106'

# 此端口是run时22端口映射的222端口
gitlab_rails['gitlab_shell_ssh_port'] = 222

#保存配置文件并退出
:wq

4. Create a project. When entering for the first time, you need to enter the new root user password. After setting it, just confirm it. The default password is root/root1234.

common problem:

Exceptions when powering off and restarting:

1. Enter the container
docker exec -ti gitlab /bin/bash
2. Restart the command
gitlab-ctl restart
3. Check the status
gitlab-ctl status
4. Grant permissions to the working directory
setfacl -R -m u:docker:rwx /data

Guess you like

Origin blog.csdn.net/wmz1932/article/details/130820270