Network Security Internet Technology Development Database Servers Mobile Phone Android Software Apple Software Computer Software News IT Information

In addition to Weibo, there is also WeChat

Please pay attention

WeChat public account

Shulou

The method and steps of installing Gitlab with Docker

2025-02-24 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Servers >

Share

Shulou(Shulou.com)06/02 Report--

Introduction to Gitlab

GitLab is a Git code hosting tool, with a free community version that allows us to build code hosting sites locally, as well as paid enterprise sites that can host code online. The traditional way is to manually download the Gitlab software package, and then build the relevant running environment. However, this method is very troublesome, and if you want to change all the configuration of the machine, you have to do it all over again. If you have learned Java, you should remember the fear of configuring environment variables when you are learning Java. So a better way is to use Docker, which is now very popular.

So what is Docker? This is a virtualized running tool whose main purpose is to package the software with the entire running environment so that we can run the software quickly without configuration. Because Docker depends on some features of the Linux kernel, Docker can only run on Linux. Docker on Windows is actually a virtual machine powered on. Docker doesn't seem to have a good Chinese community at the moment. I googled it and only found this Docker Chinese community, which seems to be okay.

Install docker

I am using Archlinux, so the installation command is as follows.

Sudo pacman-S docker

If you use other systems, you need to use the appropriate package management tools.

Once installed, take a look at the version of Docker.

Sudo docker version

A message like this should be displayed. The version of the Docker client is preferably above 1.10.

Client: Version: 1.13.1 API version: 1.26 Go version: go1.7.5 Git commit: 092cba3727 Built: Sun Feb 12 02:40:56 2017 OS/Arch: linux/amd64Server: Version: 1.13.1 API version: 1.26 (minimum version 1.12) Go version: go1.7.5 Git commit: 092cba3727 Built: Sun Feb 12 02:40:56 2017 OS/Arch: linux/amd64 Experimental: false

In this way, Docker is installed successfully.

Using Ali Cloud to accelerate Docker

The official mirror website of Docker is deployed on the external network, so our domestic download is relatively slow. Take a look at the best Docker acceleration service in China is Aliyun. Other images of Aliyun, such as Maven images, are also good.

First of all, you need to sign up for an Aliyun account, and you may need a little more information. Then go to the container Hub service console with an accelerator in the middle. After we click on it, Aliyun will create a dedicated accelerator address for us.

Then you need to check the version of the Docker client. If it is less than 1.10, you can only find the corresponding solution according to your own system version. If it is greater than or equal to 1.10, you can use the following configuration method directly. The configuration method is simple: add a section of configuration to / etc/docker/daemon.json. If the file is not available, create it.

{"registry-mirrors": [""]}

Then restart the Docker service.

Sudo systemctl daemon-reloadsudo systemctl restart docker

Download Gitlab

Once the accelerator is configured, the download will be quick. Execute the following command directly, and after a while, Docker will download the Gitlab.

Sudo docker pull gitlab/gitlab-ce:latest

Start Gitlab

Start a default configuration of Gitlab with the following command. If we only use it for native testing, replace hostname with localhost. Use the external network IP address if you need to make it accessible to the external system.

Sudo docker run-- detach\-- hostname gitlab.example.com\-- publish 443-- publish 80:80-- publish 22:22\-- name gitlab\-- restart always\-- volume / srv/gitlab/config:/etc/gitlab\-- volume / srv/gitlab/logs:/var/log/gitlab\-- volume / srv/gitlab/data:/var/opt/gitlab\ gitlab/gitlab-ce:latest

It may be slow to start for the first time and it will take about a minute to start. We can use the sudo docker ps command to view the status of all current Docker containers. When its state changes from starting to run time, it starts successfully. We can access it directly in the browser using the IP address configured above (such as localhost).

For the first time, we need to create a default administrator password, just specify one. Then we need to sign up for a regular user. How to use it in the future is very similar to a tool like Github.

Configure Gitlab

When we just start Gitlab, we need to enter a password, which is the password of the administrator user. We use root as the user name where we log in, and then we can log in to Gitlab as an administrator with the password we just set.

After logging in, click the gear icon in the upper right corner to go to the administrator page. We can set up a lot of things here. For example, by default, each user can only create 10 repositories, and we can change this setting. Click the gear on the right side of the administrator page, and then click Settings to enter the system settings. Then find the Default projects limit item, we set a small goal for it, set it 100 million, which is equivalent to an infinite warehouse. Of course, if your hard drive is full, you won't be able to create any more projects.

If these configurations still do not meet your needs, you can also configure Gitlab directly. First enter the Docker environment. We use the following command to enter the bash in the Docker environment. Gitlab is the Gitlab name you just specified.

Sudo docker exec-it gitlab / bin/bash

Then we enter the environment of Docker, which we can use as a stand-alone system. Then edit the / etc/gitlab/gitlab.rb file, which is the global configuration file for Gitlab. All options can be configured here.

Nano / etc/gitlab/gitlab.rb

I don't know the detailed configuration method either. Let's just look at the official documentation.

Update Gitlab

If you need to update the Gitlab version later, you first need to stop and delete the current Gitlab instance.

Sudo docker stop gitlabsudo docker rm gitlab

Then pull the latest version of Gitlab.

Sudo docker pull gitlab/gitlab-ce:latest

Then run Gitlab using the last configuration. Don't worry about losing data. Gitlab will automatically read these configurations as long as your volume parameters are the same as last time.

Sudo docker run-- detach\-- hostname gitlab.example.com\-- publish 443-- publish 80:80-- publish 22:22\-- name gitlab\-- restart always\-- volume / srv/gitlab/config:/etc/gitlab\-- volume / srv/gitlab/logs:/var/log/gitlab\-- volume / srv/gitlab/data:/var/opt/gitlab\ gitlab/gitlab-ce:latest

Finally, let's look at the advantages of using Docker. It's still in Gitlab's Bash. Let's enter the following commands in turn and see how we react.

Ruby-versiongit-versionredis-cli-versionpsql-version

If nothing happens, the version of the corresponding software should be displayed. We see that Gitlab uses four open source software or operating environments: ruby, git, redis, and postgresql. If we install Gitlab manually, these software must also be installed and configured separately. This task is very difficult. And if it needs to be configured on multiple machines, then the task is even greater. But if we use Docker, we don't even need to know that these software exist. We can create and run Gitlab with just two commands. This is the charm of Docker, no wonder more and more companies are using Docker.

See a seemingly good Docker tutorial, you can take a look at it.

references

Https://www.jb51.net/article/131437.htm

Https://docs.gitlab.com/omnibus/docker/README.html#gitlab-docker-images

The above is the whole content of this article, I hope it will be helpful to your study, and I also hope that you will support it.

Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.

Views: 0

*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.

Share To

Servers

Wechat

© 2024 shulou.com SLNews company. All rights reserved.

12
Report