Table of Contents
I. Introduction
2. Install Gitlab
1. Search for gitlab-ce image
2. Download the image
3. View the image
4. Create a mounted data volume in advance
5. Run the image
3. Configure Gitlab files
1. Configure the /etc/gitlab/gitlab.rb file in the container
2. Restart the container
3. Log in to Gitalb
① View the password of the initial root user
② Visit the gitlab address and enter the username and password
4. Set the language to Simplified Chinese
① Click preference
② Select Simplified Chinese
③ Save configuration
5. Change default password
① Click Preferences
② Change password
1. Foreword
The previous article talked about how to use the rpm package to install gitlab, but during the actual installation process, I encountered an error message about missing dependencies. The problem of missing dependencies is actually a distressing thing, so this article is used to introduce how to Install gitlab using Docker
2. Install Gitlab
1. Search for gitlab-ce mirror
docker search gitlab-ce
Choose different images according to your different needs. Generally, there are two choices, namely the official gitlab/gitlab-ce and the Chinese version of twang2218/gitlab-ce-zh. This article chooses the gitlab/gitlab-ce image.
2. Download image
Download the latest version of the image
docker pull gitlab/gitlab-ce
3. View mirror
After the download is complete, remember to check whether the image exists
docker images
4. Create a mounted data volume in advance
mkdir -p /data/docker/gitlab/etc # Map to the configuration directory in the Glitlab container mkdir -p /data/docker/gitlab/log # Map to the log directory in the Glitlab container mkdir -p /data/docker/gitlab/data # Map to the data directory in the Glitlab container
5. Run Image
docker run -d -p 8443:443 -p 8080:80 -p 8022:22 --restart always --name gitlab -v /data/docker/gitlab/etc:/etc/gitlab -v /data/ docker/gitlab/log:/var/log/gitlab -v /data/docker/gitlab/data:/var/opt/gitlab --privileged=true gitlab/gitlab-ce
The following explains the meaning of each parameter
docker run -d # Run in the background
-p 8443:443 # Map the container’s port 443 to the host’s port 8443
-p 8080:80
-p 8022:22
–restart always # Set the container to start automatically
–name gitlab # Set container NAMES to gitlab
-v /data/docker/gitlab/etc:/etc/gitlab # Mount the container’s /etc/gitlab to the host’s gitlab/etc directory
-v /data/docker/gitlab/log:/var/log/gitlab
-v /data/docker/gitlab/data:/var/opt/gitlab
–privileged=true # Set root permissions
gitlab/gitlab-ce # Running image name
3. Configure Gitlab files
1. Configure the /etc/gitlab/gitlab.rb file in the container
Since the host has mounted /etc/gitlab/ to the data/docker/gitlab/etc directory, you can directly enter data/docker/gitlab/etc to modify the gitlab.rb file.
vim /data/docker/gitlab/etc/gitlab.rb
The default configuration of gitlab is annotated with #, so we don’t have to modify the file, we only need to add the configuration we need.
Add the following configuration to the gitlab.rb file and save it
external_url 'The IP address of your own server' # ssh port gitlab_rails['gitlab_shell_ssh_port'] = 8022 # Modify the time zone to Shanghai gitlab_rails['time_zone'] = 'Asia/Shanghai'
2. Restart the container
docker restart container ID
3. Log in to Gitalb
① View the password of the initial root user
vim /data/docker/gitlab/etc/initial_root_password
② Visit the gitlab address, enter the user name and password
4. Set the language to Simplified Chinese
① Click preference
② Select Simplified Chinese
③ Save configuration
5. Change default password
The initial password is a bunch of garbled characters, so we definitely need to change the initial password.
① Click Preferences
② Change password
The knowledge points of the article match the official knowledge files, and you can further learn relevant knowledge. Cloud native entry-level skill treeContainer (docker)Install docker16876 people are learning the system