1. Install the docker

Docker is divided into CE and EE versions. CE is community edition (free, 7-month support cycle) and EE is enterprise edition, which emphasizes security and pays for use, 24-month support cycle.

Ubuntu Docker CE installation

The old version of Docker is called Docker or docker-engine. Run the following command to uninstall the old version:

$sudo apt-get remove docker \ docker-engine \ docker.io To verify the validity of the downloaded software package, add the GPG key of the software source. $ curl -fsSL https://mirrors.ustc.edu.cn/docker-ce/linux/ubuntu/gpg | sudo apt-key add -Copy the code

Then, we need to add the Docker software source to source.list

$ sudo add-apt-repository \ "deb [arch=amd64] https://mirrors.ustc.edu.cn/docker-ce/linux/ubuntu \ $(lsb_release -cs) \ $sudo apt-get update $sudo apt-get install docker-ce: $sudo apt-get install docker-ceCopy the code

Windows 10 PC Docker CE installation

System requirements

Docker for Windows supports the 64-bit version of Windows 10 Pro, and Hyper-V must be enabled.

The installation

Click the link below to download Stable or Edge versions of Docker for Windows. Double-click Docker for Windows Installer.exe to start the installation.

Mirror to accelerate

Due to the domestic network problems, it is very slow to pull the Docker image. It is strongly recommended to configure domestic image acceleration after Docker installation. For Windows 10, right-click the Docker icon in the lower right corner of the system and choose Settings. Open the configuration window and choose Daemon from the navigation menu on the left. Enter the accelerator address registry.docker-cn.com in the Registry mirrors column, and click Apply to save. Docker will restart and Apply the configured image address.

2. Jenkins docker deployment

Create a directory and authorize mkdir -p /home/jenkins_home && chmod -r 777 /home/jenkins_HOME To start the container docker-run -d --restart always --name Jenkins - p - 8080-8080 p, 50000:50000 - v/home/jenkins_home: / var/jenkins_home Jenkins web browser visit http://122.144.144.144:8080/ Install maven tar -xf apache-maven-3.6.0-bin.tar.gz -c /usr/local vim /etc/profile export M2_HOME=/usr/local/apache-maven-3.6.0 export CLASSPATH=$CLASSPATH:$M2_HOME/lib export PATH=$PATH:$M2_HOME/bin source /etc/profileCopy the code

3. Gitlab docker deployment

mkdir -p /home/gitlab/etc mkdir -p /home/gitlab/log mkdir -p /home/gitlab/data sudo chmod -R 777 /home/gitlab/ docker run --detach -p 443:443 -p 8088:80 -p 22:22 --name gitab --restart always -v /home/gitlab/etc:/etc/gitlab -v / home/gitlab/log: / var/log/gitlab - v/home/gitlab/data/var/opt/gitlab beginor/gitlab - ce: 10.4.1 - ce. 0 docker exec - it Gitlab /bin/bash vim /etc/gitlab/gitlab.rb external_url 'http://192.168.2.137' vim The/var/opt/gitlab/gitlab - rails/etc/gitlab yml host: 192.168.2.137 port: 8088Copy the code

Docker exec gitlab gitlab-ctl reconfigure

Docker exec gitlab gitlab-ctl restart

Browser to access http://122.144.144.144:8088

4. Configure a secret key to implement secret-free login

Ssh-keygen -t RSA Jenkins’ public key is sent to the code server and gitlab server

5. Jenkins builds

6. Webhook gitlab Settings