Introduction to GitLab
GitLab is an open source project based on Git, designed to help teams collaborate and develop software more efficiently. It is built using the Ruby on Rails framework and provides a self-hosted Git repository management tool that supports version control, code review, continuous integration and continuous deployment.
Main functions include:
- Version control: Users can create branches, merge code, and handle conflicts to ensure that the code history and change management is properly managed.
- Code review: Team members can comment and discuss submitted code through Pull Requests to ensure the quality of the code.
- Continuous Integration/Continuous Deployment (CI/CD): GitLab has built-in CI/CD functions, which support automated construction, testing and deployment processes to improve development efficiency.
- Project Management: Help the team manage project progress and tasks through Issue tracking, kanban, milestone and other functions.
GitLab also provides permission management and audit logs to ensure code security and compliance, suitable for teams of all sizes, from small open source projects to large enterprise-level applications.
GitLab is an implementationDevOPS
A classic tool for automated development, operation and maintenance pipelines.
Set the GITLAB_HOME path
Set up one firstGITLAB_HOME
Environment variable, working directory for gitlab. There are 2 ways:
- Write to the environment variable configuration file (recommended). exist
File directory creation at the same level
.env
document. WriteGITLAB_HOME=/srv/gitlab
- Add to the shell's startup configuration file.
echo "GITLAB_HOME=/srv/gitlab" >> ~/.bash_profile
After adding configuration in the second way, usesource ~/.bash_profile
Command to make the configuration take effect
Create a docker mount directory
Go to the previous step setting$GITLAB_HOME
In the directory, create newdata
, logs
, config
folders.
As shown below:
Host directory
Container internal directory
illustrate
$GITLAB_HOME/data
/var/opt/gitlab
Stores application data.
$GITLAB_HOME/logs
/var/log/gitlab
Stores logs.
$GITLAB_HOME/config
/etc/gitlab
Stores the GitLab configuration files.
Get the available version of GitLab
# Mirror name format:gitlab/gitlab-ce:<version>-ce.0 # Specify a fixed version of the imagegitlab/gitlab-ce:17.6.2-ce.0 # Use the latest version of the imagegitlab/gitlab-ce:latest
Write a file
:
version: '3.6' services: gitlab: image: gitlab/gitlab-ce:17.6.2-ce.0 container_name: gitlab restart: always hostname: '' environment: GITLAB_OMNIBUS_CONFIG: | external_url ':8929' gitlab_rails['gitlab_shell_ssh_port'] = 2424 ports: - '8929:8929' - '443:443' - '2424:22' volumes: - '$GITLAB_HOME/config:/etc/gitlab' - '$GITLAB_HOME/logs:/var/log/gitlab' - '$GITLAB_HOME/data:/var/opt/gitlab' shm_size: '256m'
passGITLAB_OMNIBUS_CONFIG
Environment variables, configurationexternal_url
Parameters, set the HTTP address of the repository.
ports
port map toGITLAB_OMNIBUS_CONFIG
The relevant configuration items shall prevail.
Start docker
docker compose up -d
The container starts for the first time and takes several minutes, please be patient.
After successful startup, the container status is(health: starting)
Become(healthy)
. As shown below:
NAME IMAGE COMMAND SERVICE CREATED STATUS PORTS gitlab gitlab/gitlab-ce:17.6.2-ce.0 "/assets/wrapper" gitlab 2 hours ago Up 12 seconds (health: starting) 0.0.0.0:443->443/tcp, :::443->443/tcp, 80/tcp, 0.0.0.0:8929->8929/tcp, :::8929->8929/tcp, 0.0.0.0:2424->22/tcp, [::]:2424->22/tcp NAME IMAGE COMMAND SERVICE CREATED STATUS PORTS gitlab gitlab/gitlab-ce:17.6.2-ce.0 "/assets/wrapper" gitlab 3 hours ago Up 51 minutes (healthy) 0.0.0.0:443->443/tcp, :::443->443/tcp, 80/tcp, 0.0.0.0:8929->8929/tcp, :::8929->8929/tcp, 0.0.0.0:2424->22/tcp, [::]:2424->22/tcp
View the container run log:
sudo docker logs -f gitlab
Through the previous configurationexternal_url
, access the GitLab project address and log in to the root account.
- The username is:
root
- User password view file: host machine
$GITLAB_HOME/config/initial_root_password
or inside the container/etc/gitlab/initial_root_password
Note: The password file is automatically deleted in the first container restart after 24 hours.
Basic configuration
GITLAB_OMNIBUS_CONFIG
GITLAB_OMNIBUS_CONFIG
Environment variables, allow presetsFile configuration items.
It has the following characteristics:
- More than in the container
The configuration file is read first.
- It will only be loaded when the system starts, and will not be modified directly
document.
- Allows multiple configuration items to be set, use
;
Symbols separated.
The configuration can include GitLab project address, database configuration, etc. For details, please see:File configuration template
external_url
: Project homepage. like:":8929"
gitlab_rails['gitlab_shell_ssh_port']
: SSH port. like:2424
gitlab_rails['initial_root_password']
: The preset root user password when the project is initialized.
When the project is first started, environment variables can also be injected into the container.GITLAB_ROOT_PASSWORD
, preset the login password of the root user.
Docker run commands are as follows:
sudo docker run --detach
–hostname
–env GITLAB_OMNIBUS_CONFIG=“external_url ‘:8929’; gitlab_rails[‘gitlab_shell_ssh_port’] = 2424”
–publish 8929:8929 --publish 2424:22
–name gitlab
–restart always
–volume $GITLAB_HOME/config:/etc/gitlab
–volume $GITLAB_HOME/logs:/var/log/gitlab
–volume $GITLAB_HOME/data:/var/opt/gitlab
–shm-size 256m
gitlab/gitlab-ce:-ce.0
Modify configuration
- Enter the container:
sudo docker exec -it gitlab /bin/bash
- Modify the configuration file:
editor /etc/gitlab/
- Overload configuration:
gitlab-ctl reconfigure
Chinese settings
- Global settings: Menu in the lower left corner
Admin
, click:Settings
-Preferences
。 - Page found
Localization
-Default language
User personalization settings: click on the user avatar in the upper left corner and select the drop-down box.Preferences
. Page foundLocalization
- Language
The current user must have changedUser personalized settings
, to take effect:
In the user menu at the top right of the page, select Settings.
After entering the Settings page, click the "Preferences" option in the navigation bar on the left.
In the Preferences page, find the "Localization" area and change the "Language" option to "Simplified Chinese".
Click the "Save changes" button at the bottom of the page to save the language settings.
Database configuration
sinceGitLab 16.0
From the beginning, GitLab uses 2 database connections by default. We can disable it, return to the original single-connect mode.
sudo docker exec -it gitlab editor /etc/gitlab/ gitlab_rails['databases']['ci']['enable'] = false sudo docker restart gitlab
System mailbox configuration
Modify the configuration file:/etc/gitlab/
Reload the configuration to make it effective:gitlab-ctl reconfigure
gitlab_rails[‘smtp_enable’] = true
gitlab_rails[‘smtp_address’] = “”
gitlab_rails[‘smtp_port’] = 465
gitlab_rails[‘smtp_user_name’] = “smtp user”
gitlab_rails[‘smtp_password’] = “smtp password”
gitlab_rails[‘smtp_domain’] = “”
gitlab_rails[‘smtp_authentication’] = “login”
gitlab_rails[‘smtp_enable_starttls_auto’] = true
gitlab_rails[‘smtp_openssl_verify_mode’] = ‘peer’
If your SMTP server does not like the default ‘From: gitlab@localhost’ you can change the ‘From’ with this setting.
gitlab_rails[‘gitlab_email_from’] = ‘gitlab@’
gitlab_rails[‘gitlab_email_reply_to’] = ‘noreply@’
If your SMTP server is using a self signed certificate or a certificate which is signed by a CA which is not trusted by default, you can specify a custom ca file. Please note that the certificates from /etc/gitlab/trusted-certs/ are not used for the verification of the SMTP server certificate.
gitlab_rails[‘smtp_ca_file’] = ‘/path/to/your/’
Example: QQ exmail (Tencent Corporate Email)
gitlab_rails['smtp_enable'] = true gitlab_rails['smtp_address'] = "" gitlab_rails['smtp_port'] = 465 gitlab_rails['smtp_user_name'] = "xxxx@" gitlab_rails['smtp_password'] = "password" gitlab_rails['smtp_authentication'] = "login" gitlab_rails['smtp_enable_starttls_auto'] = false gitlab_rails['smtp_tls'] = true gitlab_rails['gitlab_email_from'] = 'xxxx@' gitlab_rails['smtp_domain'] = ""
/17.6/ee/install/docker/
Steps after installing GitLab: /17.6/ee/install/next_steps.html
This is the end of this article about installing gitlab using docker compose. For more related content on installing gitlab by docker compose, please search for my previous articles or continue browsing the related articles below. I hope everyone will support me in the future!