docker installs Chinese version of gitlab (Reprint)

Posted by KeitaroHimura on Tue, 28 Apr 2020 06:14:24 +0200

1.pull image in Chinese:

docker pull beginor/gitlab-ce:11.3.0-ce.0

2. Create directory:

Generally, GitLab's configuration (etc), log (log) and data (data) are placed outside the container for later upgrade, so please prepare these three directories first.

mkdir -p /usr/local/gitlab/etc
mkdir -p /usr/local/gitlab/log
mkdir -p /usr/local/gitlab/data

3. Modify directory permission:

chmod 777 /usr/local/gitlab/etc
chmod 777 /usr/local/gitlab/log
chmod 777 /usr/local/gitlab/data

4. Operation:

After these three directories are ready, you can start to run the Docker image:

docker run --detach --publish 8443:443 --publish 8888:80 --publish 8222:22 --name gitlab --restart unless-stopped --volume /usr/local/gitlab/etc:/etc/gitlab --volume /usr/local/gitlab/log:/var/log/gitlab --volume /usr/local/gitlab/data:/var/opt/gitlab --privileged=true beginor/gitlab-ce:11.3.0-ce.0

-- publish 8443:443: Map http: 443 to external port 8443
-- publish 8888:80: Map web: 80 to external port 8888
-- publish 8222:22: Map ssh: 22 to external port 8222
-- name gitlab running container name
-- restart unless stopped
-- volume /usr/local/gitlab/etc:/etc/gitlab mount directory
-- volume /usr/local/gitlab/log:/var/log/gitlab mount directory
-- volume /usr/local/gitlab/data:/var/opt/gitlab mount directory
-- privileged=true enables the root in the container to have real root privileges. Otherwise, the root in the container is only a common external user right

5. Visit:

Wait a moment, and then open the browser: ip address: 8888 (http://192.168.2.212:8888/)

Modify the password as 123456789, and complete the modification: log in with the user name root and the password as 123456789.

 

Mail sending configuration:

cd /usr/local/gitlab/etc    Jump to mount directory

vim gitlab.rb

Open the POP3/SMTP service of qq mailbox and save the authorization code:

Add at the end of gitlab.rb:

gitlab_rails['smtp_enable'] = true
gitlab_rails['smtp_address'] = "smtp.qq.com"
gitlab_rails['smtp_port'] = 465
gitlab_rails['smtp_user_name'] = "1066394274@qq.com"
gitlab_rails['smtp_password'] = "Authorization code"
gitlab_rails['smtp_domain'] = "smtp.qq.com"
gitlab_rails['smtp_authentication'] = "login"
gitlab_rails['smtp_enable_starttls_auto'] = true
gitlab_rails['smtp_tls'] = true
gitlab_rails['gitlab_email_from'] = '1066394274@qq.com'

Inside the container:

docker exec -it gitlab bash

Restart effective:

gitlab-ctl reconfigure

Test configuration for success:

Gitlab rails console access to the console

Notify.test_email('1107592245 ',' email title ',' email body '). deliver_now

Send test mail:

A new message was found:

Click on the link:

This will

    http://d7136f987efd/users/confirmation?confirmation_token=KWEVNipWBy2DjkFji4-X

d7136f987efd is replaced by 192.168.2.212:8080

Activation succeeded after access.

Generate SSH private key:

[root@localhost ~]# ssh-keygen -o -t rsa -C "1066394274@qq.com" -b 4096
Generating public/private rsa key pair.
Enter file in which to save the key (/root/.ssh/id_rsa): 
Enter passphrase (empty for no passphrase): 
Enter same passphrase again: 
Your identification has been saved in /root/.ssh/id_rsa.
Your public key has been saved in /root/.ssh/id_rsa.pub.
The key fingerprint is:
SHA256:DYH3I8KhprEb/N6E0ErkR+Chjes4rwo1orSqhrtOCBE 1066394274@qq.com
The key's randomart image is:
+---[RSA 4096]----+
|E o    ..        |
| * o  o ..       |
|+ + .o o..       |
| =.oo o .oo      |
|+o*=o  .S...     |
|B+*= .           |
|B+.+. .          |
|=+. .o           |
|%=... .          |
+----[SHA256]-----+
[root@localhost ~]# cat ~/.ssh/id_rsa.pub
ssh-rsa AAAAB3NzaC1yc2EAAAADAQABAAACAQDSMr3ihBbSbjXQaJTjxBNiMpExUMz0J4LZ/2xCxYpUWvQs/9pmbhCl7Do9Y8TbebBy3yxUVINB8yIqgKwsX3XnXsE3TEHXKI+/dbrjlxhK49dghT6kyJwsCE1fQ4JbUz8cX7WsYysuOR326Wajdud+e14KGuuozV3ooAfmhBnTqEvj7PULCOMsLD1bftMmNvbeVRW4KSE7wWrdGurD3v5gAPMhfDDAs72g8qApsW0nyunnMd+OyQRtsD7V+y5Tlk3f1pnEE2yTXxYg5REHQhMyrfoH+MHGAHQH226sFQ106Y8IiJPIAs4zL9CTkiz4dPsOmpzyTt5f7RjJhyLUI0rM5StkZsu/bbchgMppQK4/CZtg/rBIygRB0zmisgdDZA2kpfvPmM7MCBFrYdIuutz/HjIkyg8+RnvTDEo0CBgbs1X0Nm3zL7P6MB6RlW4Zsz5fSrn49FH3pylyR2wkkebd86L53p+3117SrBH2FQEYsgwYGpcOBv8ZC3w25+7/ExrCoyx6VRbf4bqsyZ7gsX8sAHsRlEeCpiI1kGZXvYJj5jFoaq3zsDTEwn6miQINJYJVIhOnPUsDHxK7IHLu2Grd/W6EtZaLJ1je4xXpgdMDMe7/HM8rZ0RPXP90xkg/7hXmGLxd+exlp1t9GkjZ5ogQ2ZSyBSMt5oN5oGzUEBjLeQ== 1066394274@qq.com

 

 

Project path error:

docker exec -it gitlab vim /etc/gitlab/gitlab.rb

 

Modify to current server ip; stop deleting container:

docker stop gitlab

docker rm gitlab

Restart the system:

reboot

Run container:

docker run --detach --publish 8443:443 --publish 8888:8888 --publish 8222:22 --name gitlab --restart unless-stopped --volume /usr/local/gitlab/etc:/etc/gitlab --volume /usr/local/gitlab/log:/var/log/gitlab --volume /usr/local/gitlab/data:/var/opt/gitlab --privileged=true beginor/gitlab-ce:11.3.0-ce.0

    Change the internal port number from 80 to 8888 consistent with the external port

At this time, you can use http and ssh to pull successfully:

    

 

upgrade

For small version upgrade (for example, upgrade from 8.8.2 to 8.8.3), refer to the official instructions, stop the original container, and then delete:

docker stop gitlab
docker rm gitlab

Then pull a new version of the image down:

docker pull beginor/gitlab-ce:11.3.0-ce.0

Also run with the original run command:

docker run 
    --detach 
    --publish 8443:443 
    --publish 8080:80 
    --name gitlab 
    --restart unless-stopped 
    --volume /mnt/sda1/gitlab/etc:/etc/gitlab 
    --volume /mnt/sda1/gitlab/log:/var/log/gitlab 
    --volume /mnt/sda1/gitlab/data:/var/opt/gitlab 
    beginor/gitlab-ce:11.3.0-ce.0

For large version upgrade (for example, upgrade from 8.7.x to 8.8.x), there may be errors with the above operations. If there are errors, you can try to log in to the container, you can use docker exec or ssh to execute the following commands in turn:

gitlab-ctl reconfigure
gitlab-ctl restart

 

Error handling:

The docker container prompts that vim is not installed:

apt-get update

apt-get install vim

Stop all container s:

docker stop $(docker ps -a -q)

Delete all container s:

docker rm $(docker ps -a -q)

Topics: Programming GitLab Docker ssh vim