How to deploy gitlab using Docker-compose

How to deploy gitlab using Docker-compose

Docker-compose deploys gitlab

1. Install Docker

Install Necessary Tools

Copy the code as follows:
[root@vm_10_14_centos ~]# yum -y install yum-utils device-mapper-persistent-data lvm2

Add Docker-ce image source and install

[root@vm_10_14_centos ~]# yum-config-manager --add-repo
http://mirrors.aliyun.com/docker-ce/linux/centos/docker-ce.repo
[root@vm_10_14_centos ~]# yum makecache fast
[root@vm_10_14_centos ~]# yum -y install docker-ce[root@gitlab ~]# yum makecache fast
[root@vm_10_14_centos ~]# yum -y install docker-ce
[root@vm_10_14_centos ~]# systemctl start docker
[root@vm_10_14_centos ~]# systemctl enable docker
Created symlink from /etc/systemd/system/multi-user.target.wants/docker.service to /usr/lib/systemd/system/docker.service.

Add Docker image acceleration

[root@vm_10_14_centos ~]# vim /etc/docker/daemon.json
{
"registry-mirrors": ["https://9w1hl6qt.mirror.aliyuncs.com"]
}
[root@vm_10_14_centos ~]# systemctl daemon-reload
[root@vm_10_14_centos ~]# systemctl restart docker
[root@vm_10_14_centos ~]# rpm -qa docker
[root@vm_10_14_centos ~]# rpm -qa docker-ce
docker-ce-18.09.0-3.el7.x86_64
[root@vm_10_14_centos ~]# docker --version
Docker version 18.09.0, build 4d60db4
[root@vm_10_14_centos ~]# docker version
Client:
 Version: 18.09.0
 API version: 1.39
 Go version: go1.10.4
 Git commit: 4d60db4
 Built: Wed Nov 7 00:48:22 2018
 OS/Arch: linux/amd64
 Experimental: false

Server: Docker Engine - Community
 Engine:
 Version: 18.09.0
 API version: 1.39 (minimum version 1.12)
 Go version: go1.10.4
 Git commit: 4d60db4
 Built: Wed Nov 7 00:19:08 2018
 OS/Arch: linux/amd64
 Experimental: false

2. Install Docker-compose

Download the Docker-compose binary and add execution permissions

[root@vm_10_14_centos ~]# curl -L https://github.com/docker/compose/releases/download/1.23.2/docker-compose-`uname -s`-`uname -m` -o /usr/local/bin/docker-compose
 % Total % Received % Xferd Average Speed ​​Time Time Time Current
         Dload Upload Total Spent Left Speed
100 617 0 617 0 0 959 0 --:--:-- --:--:-- --:--:-- 958
100 11.2M 100 11.2M 0 0 1824k 0 0:00:06 0:00:06 --:--:-- 2422k
[root@vm_10_14_centos ~]# chmod +x /usr/local/bin/docker-compose
[root@vm_10_14_centos ~]# docker-compose --version
docker-compose version 1.23.2, build 1110ad01

3. Install Gitlab

(1) Edit the yml file of docker-compose

[root@vm_10_14_centos ~]# mkdir gitlab
[root@vm_10_14_centos ~]# cd gitlab/
[root@vm_10_14_centos gitlab]# vim docker-compose.yml 
version: '2'
services:
 gitlab:
  image: 'twang2218/gitlab-ce-zh:11.1.4'
  container_name: "gitlab"
  restart: unless-stopped
  privileged: true
  hostname: 'gitlab'
  environment:
  TZ: 'Asia/Shanghai'
  GITLAB_OMNIBUS_CONFIG: |
   external_url 'http://129.204.133.242'
   gitlab_rails['time_zone'] = 'Asia/Shanghai'
   gitlab_rails['smtp_enable'] = true
   gitlab_rails['smtp_address'] = "smtp.aliyun.com"
   gitlab_rails['smtp_port'] = 465
   gitlab_rails['smtp_user_name'] = "[email protected]" #Use your own aliyun mailboxgitlab_rails['smtp_password'] = "axbc1kof"
   gitlab_rails['smtp_domain'] = "aliyun.com"
   gitlab_rails['smtp_authentication'] = "login"
   gitlab_rails['smtp_enable_starttls_auto'] = true
   gitlab_rails['smtp_tls'] = true
   gitlab_rails['gitlab_email_from'] = '[email protected]'
   gitlab_rails['gitlab_shell_ssh_port'] = 22
  ports:
  - '80:80'
  - '443:443'
  - '22:22'
  volumes:
  - /opt/gitlab/config:/etc/gitlab
  - /opt/gitlab/data:/var/opt/gitlab
  - /opt/gitlab/logs:/var/log/gitlab

(2) Create relevant directories

[root@vm_10_14_centos gitlab]# mkdir /opt/gitlab/{config,data,logs} -p
[root@vm_10_14_centos gitlab]# ls -l /opt/gitlab/
total 12
drwxr-xr-x 2 root root 4096 Dec 8 11:35 config
drwxr-xr-x 2 root root 4096 Dec 8 11:35 data
drwxr-xr-x 2 root root 4096 Dec 8 11:35 logs

(3) Pull the Chinese version of gitlab image

[root@vm_10_14_centos gitlab]# docker pull twang2218/gitlab-ce-zh:11.1.4
11.1.4: Pulling from twang2218/gitlab-ce-zh
8ee29e426c26: Pull complete 
6e83b260b73b: Pull complete 
e26b65fd1143: Pull complete 
40dca07f8222: Pull complete 
b420ae9e10b3: Pull complete 
a218309dd589: Pull complete 
5c60fd7ba0ce: Pull complete 
659c2144b5a3: Pull complete 
8289bbac0d0e: Pull complete 
31bbd150e8a7: Pull complete 
9114e78243fa: Pull complete 
0b97fa2153bc: Pull complete 
308c7e15be6a: Pull complete 
b7f31b8e487d: Pull complete 
cbbb6dec5000: Pull complete 
0241c9ad6a16: Pull complete 
7fa6f0b53edd: Pull complete 
1c2861e152b2: Pull complete 
0536f3466f66: Pull complete 
Digest: sha256:3c2372e3285e6d6933ddebb5ee3ae0c4bbf7cb235084e54d33d7f0ddf4813c4a
Status: Downloaded newer image for twang2218/gitlab-ce-zh:11.1.4
[root@vm_10_14_centos gitlab]# docker image ls
REPOSITORY TAG IMAGE ID CREATED SIZE
twang2218/gitlab-ce-zh 11.1.4 1935cc9f8798 4 months ago 1.61GB

(4) Start the gitlab container

[root@vm_10_14_centos gitlab]# docker-compose up -d
Creating network "gitlab_default" with the default driver
Creating gitlab ... error

ERROR: for gitlab Cannot start service gitlab: b'driver failed programming external connectivity on endpoint gitlab (9308ca74b8491c556263eac9fb9b0abcb25258d9e2df5733fc4d9143d6b18dcc): Error starting userland proxy: listen tcp 0.0.0.0:22: bind: address already in use'

ERROR: for gitlab Cannot start service gitlab: b'driver failed programming external connectivity on endpoint gitlab (9308ca74b8491c556263eac9fb9b0abcb25258d9e2df5733fc4d9143d6b18dcc): Error starting userland proxy: listen tcp 0.0.0.0:22: bind: address already in use'
ERROR: Encountered errors while bringing up the project.
 
[root@vm_10_14_centos gitlab]# vim /etc/ssh/sshd_config 
[root@vm_10_14_centos gitlab]# systemctl restart sshd
[root@vm_10_14_centos gitlab]# netstat -tulnp |grep 22
tcp 0 0 0.0.0.0:60022 0.0.0.0:* LISTEN 4044/sshd

It should be noted here that since the gitlab container needs to use port 22 and cannot conflict with the host, you need to modify the listening port of the host's sshd service

[root@vm_10_14_centos gitlab]# docker-compose ps
Name Command State Ports
--------------------------------------------------------------------------------------------
------------------------
gitlab /assets/wrapper Up (healthy) 0.0.0.0:22->22/tcp, 0.0.0.0:443-
>443/tcp, 0.0.0.0:80->80/tcp

(5) Gitlab settings start up

[root@vm_10_14_centos gitlab]# chmod +x /etc/rc.local
[root@vm_10_14_centos gitlab]# ls -l /etc/rc.local
lrwxrwxrwx. 1 root root 13 Jul 7 16:43 /etc/rc.local -> rc.d/rc.local
[root@vm_10_14_centos gitlab]# echo "cd /root/gitlab && docker-compose up -d" >>
/etc/rc.local
[root@gitlab gitlab]# tail -1 /etc/rc.local
cd /root/gitlab && docker-compose up -d

(6) GitLab management interface

Address: http://129.204.133.242

Account: root

Password: Set for first login



You may also be interested in:
  • Explain the deployment and configuration of Clickhouse Docker cluster with examples
  • Detailed explanation of docker-compose deployment php project example
  • Docker-compose one-click deployment of gitlab Chinese version method steps
  • A brief analysis of the problem of mysql being inaccessible when deployed with docker-compose
  • Tutorial on how to quickly deploy clickhouse using docker-compose

<<:  JavaScript implements the drag slider puzzle verification function (html5, canvas)

>>:  MySql 5.6.36 64-bit green version installation graphic tutorial

Recommend

Detailed explanation of common commands in Docker repository

Log in docker login Complete the registration and...

How to design a web page? How to create a web page?

When it comes to understanding web design, many p...

Import csv file into mysql using navicat

This article shares the specific code for importi...

Detailed explanation of props and context parameters of SetUp function in Vue3

1. The first parameter props of the setUp functio...

Analysis of the project process in idea packaging and uploading to cloud service

one. First of all, you have to package it in idea...

Detailed steps for Linux account file control management

In the Linux system, in addition to various accou...

How to use display:olck/none to create a menu bar

The effect of completing a menu bar through displ...

Docker overlay realizes container intercommunication across hosts

Table of contents 1. Docker configuration 2. Crea...

Canvas draws scratch card effect

This article shares the specific code for drawing...

Detailed explanation of Javascript basics loop

Table of contents cycle for for-in for-of while d...

How to use CSS to pull down a small image to view a large image and information

Today I will talk about a CSS special effect of h...

js to achieve a simple carousel effect

This article shares the specific code of js to ac...

Application of anchor points in HTML

Set Anchor Point <a name="top"><...

Detailed explanation of Angular parent-child component communication

Table of contents Overview 1. Overview of input a...