preface
GitLab is an online repository hosting software that uses Git as a code management tool to access public and private projects through a Web interface. It has similar functionality to Github, with the ability to browse source code and manage defects and comments. Manages team access to the repository, makes it easy to browse committed versions and provides a file history library.
Due to the lack of a Git management tool, the team built Gitlab service based on Docker. This paper records some simple processes of this construction.
1. Installation environment
- Operating system: Redhat 7
- Docker: 19.03.8
- Required memory: 8GB
Second, set up GitLab
1. Find the GitLab image
docker search gitlab
Copy the code
Query result:
2. Pull the Gitlab Docker image
For the above query results, I choose the community edition (Gitlab/Gitlab-CE) to use, because it is free and has enough functions to meet the daily git server requirements.
docker pull gitlab/gitlab-ce:latest
Copy the code
3. Export and import gitlab-CE image package
Due to the Intranet environment, you need to export the image package and import it to the Intranet server.
Docker save -o gitlab.tar gitlab/gitlab-ce:latest // Export to local current folder docker load < gitlab/gitlab-ce // Go to the folder where the image docker is imported Images / / viewCopy the code
4. Network (optional)
Consider the possibility of other containers or other access to establish network communication, but are not used at this time.
docker network create gitlab_net
Copy the code
5. Start the image
docker run -itd --net=gitlab_net -p 9443:443 -p 80:80 -p 9922:22 -v /opt/local/gitlab/etc:/etc/gitlab -v /opt/local/gitlab/log:/var/log/gitlab -v /opt/local/gitlab/opt:/var/opt/gitlab --restart always --privileged=true --name gitlab-prod gitlab/gitlab-ceCopy the code
Command description:
-t reassigns a pseudo-input terminal to the container. -d is usually used in the background with -i to run the container and return the container ID --net=gitlab_net: specifies the network mode -p 9443: Map port 443 in the container to port 9443 on the host, which is HTTPS port. -P 80:80 Map port 80 in the container to port 9980 on the host, which is the port to access gitLab. -P 9922:22 Map port 22 in the container to port 9922 on the host, This is SSH access port - v/opt/local/gitlab/etc, / etc/gitlab - v/opt/local/gitlab/log: / var/log/gitlab - v / opt/local/gitlab/opt, / var/opt/gitlab: directory mounted to the container hosting/opt/local/gitlab directory, convenient to modify and data persistence. Name gitlab-prod: Set the name of the container. Gitlab /gitlab-ce: use the imageCopy the code
6. Modify gitlab.rb
Run the vi editor to open the gitlab.rb file using the vi editor: vi /opt/local/ gitlab-is /etc/gitlab/gitlab.rb //Copy the code
//external_url set //external_url set to http://10.10.129.144 // SSH host IP set //gitlab_rail['gitlab_ssh_host']='10.10.129.144' // SSH port Settings //gitlab_rail['gitlab_shell_ssh_port']=9922Copy the code
:wq // Save the configuration and exitCopy the code
7. Enter the GitLab container and the configuration takes effect and restart
Docker exec it gitlab-prod /bin/bash // gitlab-ctl reconfigure // gitlab-ctl restart // gitlab exit // Out of the containerCopy the code
8, check detection
The IP address of the browser is http://10.10.129.144, so the browser is http://10.10.129.144. If you log in to the root account for the first time, you need to change the password.
If the installation is successful, you can check whether the port, firewall, and container are running.
Netstat -ntlp // Firewall start: systemctl start firewalld Check the status: systemctl status firewalld stop: Systemctl disable firewalld Disable: systemctl stop firewalld // container docker container lsCopy the code
9. Other problems
Just on the new Linux installation Docker – CE, run after the Docker run the hello world – error always connect to the daemon at Docker Unix: / / / var/run/Docker. The sock. Is the docker daemon running?
$systemctl daemon-reloadCopy the code
Other configurations
Gitlab client related mail configuration, close registration function, backup configuration, CI/CD function configuration, SSH key configuration and so on
The last
I take notes on this for the convenience of developing and testing