A brief introduction
Most of the time we think of GitLab as a distributed Git code management tool, but there’s more to it than that. This paper mainly records the construction of GitLab service based on Docker. As for its basic use and more functions it should play, I expect it will be applied in subsequent practice. Let’s get down to business and get ready to install GitLab.
Ii. Install and deploy GitLab service
2.1 Downloading an Image
There are community edition (CE) and Enterprise Edition (EE) for GitLab, and we use the community edition here. First, as is my custom, after deciding what image to use, I will directly pull the image to the host, using the following command:
$ docker pull gitlab/gitlab-ce:latest
This mirror image is a little big, so we need to be patient for a while.
By the time mirror pull is done, you’ll know what I’m going to do next. That’s right, now we’re going to look at some details about the mirror. Before we do that, let’s take a look at the mirror image, 1.78GB, which is pretty big.
Then run the following command to view details about the image:
$ docker inspect gitlab/gitlab-ce:latest
Some screenshots are as follows:
I’m generally concerned about the ports exposed and the data volume directory, as you can see, there are several data volumes that we need for persistence. For some reason, I particularly like to map the host directory for stateful service persistence in a standalone environment.
Run the following command to create three mount directories on the host. Of course, this directory can be created automatically.
$ mkdir -p /docker_volume/gitlab/config
$ mkdir -p /docker_volume/gitlab/data
$ mkdir -p /docker_volume/gitlab/logs
Next we are ready to start the container.
2.2 Starting the container using the docker command
$docker run -d –restart=unless-stopped -p 30020:443 -p 30021:80 -p 30022:22 -h 192.168.225.129 -v /docker_volume/gitlab/config:/etc/gitlab -v /docker_volume/gitlab/data:/var/opt/gitlab -v /docker_volume/gitlab/logs:/var/log/gitlab –name gitlab gitlab/gitlab-ce:latest
Run the following command to check the status of the container we just started:
$ docker container ls -f name=gitlab
Next we will use Rancher to manage containers, first deleting containers:
$ docker container rm -f gitlab
2.3 Deploying GitLab service in Rancher
We have deployed the service in Rancher several times in the last Docker Battle to the End series. You should be able to use it well. Just follow the instructions above to start the container with the Docker command and map it to the Rancher service deployment operation. The screenshots are as follows:
At this point, our GitLab service is running in the container. We can delete or restart the container at any time without worrying about losing our data, because we have persisted the data to our host /docker_volume/ GitLab directory. If you want to customize the configuration, you can also change it in the /docker_volume/gitlab/config directory. Next, let’s visit GitLab’s visual management interface.
3. Visual management of GitLab
3.1 the initialization
Browser visit: http://192.168.225.129:30021, for the first time to visit need to reset the root account password, the password here we assume that is set to 123456 (not too simple, otherwise can’t set success)
After the password is set, you can log in as user root. The home page after login is as follows:
3.2 Creating a Project
Click [Create a project] on the home page to Create a project. Of course, a series of user permissions and other Settings need to be set before it is used in actual work.
3.3 Managing projects using Git Tools
This is done from a Git client on our local machine
$git clone http://192.168.225.129:30021/root/test.git/
Input user name root and password 123456 to clone the successful project, and then submit the project you need to push up, I believe that every developer will operate, there is no more introduction here.
Use a summary
This practice document demonstrates how to deploy GitLab from a container and its simplicity of use, which is relatively simple overall. In the future, we will not only use it as a Git version management tool, but will probably touch on its CI/CD function. If you have any questions or any errors in the article, feel free to leave a comment in the comments section.