GitLab is a warehouse management software based on the Git version control system with rich functions, including project management, code review, CI/CD and team management. This article will introduce how to use Dcoker to deploy GitLab on a Linux system and conduct simple configuration and testing.
Before deploying Gitlab, we need to install Docker. Here we use Ubuntu 18.04 system and execute the following command to install docker:
sudo apt-get update sudo apt-get install docker.io
After installing Docker, check whether Docker is installed successfully:
docker --version
If you see Docker version information, Docker is installed successfully.
Execute the following command to start the Gitlab container:
sudo docker run --detach --hostname gitlab.example.com \ --publish 443: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
Among them, gitlab.example.com
is Gitlab's domain name, /srv/gitlab/config
, /srv/gitlab/logs
, /srv/gitlab/data
are Gitlab's configuration folder, respectively. Log folder, data folder.
After the container is running, we need to obtain the password of the default administrator and execute the following command:
sudo docker exec -it gitlab /bin/bash
After entering the container, execute the following command:
gitlab-rails console production u=User.where(id:1).first u.password='your_new_password_here' u.password_confirmation='your_new_password_here' u.save
This is done Reset the administrator password and exit the container.
Gitlab uses Sendmail by default to send emails. If you want to use SMTP to send emails, you need to change the configuration file. Here we use QQ mailbox as email. If you use other mailboxes, please change the SMTP address, port, username and password according to the actual situation.
First, create or edit gitlab.rb in the Gitlab configuration folder. You can use the following command to create the file and write the configuration:
sudo touch /srv/gitlab/config/gitlab.rb sudo echo "gitlab_rails['smtp_enable'] = true" >> /srv/gitlab/config/gitlab.rb sudo echo "gitlab_rails['smtp_address'] = \"smtp.qq.com\"" >> /srv/gitlab/config/gitlab.rb sudo echo "gitlab_rails['smtp_port'] = 465" >> /srv/gitlab/config/gitlab.rb sudo echo "gitlab_rails['smtp_user_name'] = 'your_qq_email_address'" >> /srv/gitlab/config/gitlab.rb sudo echo "gitlab_rails['smtp_password'] = 'your_qq_email_password'" >> /srv/gitlab/config/gitlab.rb sudo echo "gitlab_rails['smtp_domain'] = \"smtp.qq.com\"" >> /srv/gitlab/config/gitlab.rb sudo echo "gitlab_rails['smtp_authentication'] = \"login\"" >> /srv/gitlab/config/gitlab.rb sudo echo "gitlab_rails['smtp_enable_starttls_auto'] = true" >> /srv/gitlab/config/gitlab.rb sudo echo "gitlab_rails['smtp_tls'] = true" >> /srv/gitlab/config/gitlab.rb
Pay attention to changing the QQ email and password in the configuration.
After changing the configuration, you need to restart Gitlab for the configuration to take effect. Execute the following command:
sudo docker restart gitlab
After that, you can access Gitlab On the management page, enter the administrator account and new password to enter the system.
This article only introduces the simple deployment and configuration of GitLab. For more detailed configuration parameters and information, please refer to the official GitLab documentation.
The above is the detailed content of A brief analysis of how to use Dcoker to deploy GitLab on Linux. For more information, please follow other related articles on the PHP Chinese website!