Deployment environment version

The Rancher – server v1.6.26

Ubuntu16.04 Installing Docker 18.03.0 CE

CentOS7 install Docker 18.06.3 CE Community Edition

Docker installation

(一) ubuntu16.04

Sudo apt-get remove docker docker-engine docker-ce docker. IO sudo apt-get remove docker docker-engine docker-ce docker

Sudo apt-get update sudo apt-get update

3, install the following package to enable apt to use HTTPS to use repository sudo apt-get install -y apt-transport-https ca-certificates curl software-properties-common

4, add the Docker official GPG key curl – fsSL https://download.docker.com/linux/ubuntu/gpg | sudo apt — the key to add

5, use the following command to set up stable repository sudo add apt – repository “deb [arch = amd64] https://download.docker.com/linux/ubuntu $(lsb_release -cs) stable”

Sudo apt-get update sudo apt-get update

Docker-ce apt-Cache Madison Docker-CE apt-Cache Madison Docker-CE

8. On production systems, it may be necessary to install a specific version of Docker CE, Sudo apt-get install docker-ce=18.03.0~ce-0~ Ubuntu instead of always using the latest version (here is 18.03.0~ce-0~ Ubuntu compatible with Rancher1.6.17)

Docker status systemctl status docker

Docker sudo systemctl start docker sudo systemctl start docker

(二) centos7

Docker requires a CentOS kernel version later than 3.10. Check the prerequisites on this page to verify whether your CentOS version supports Docker. Check your current kernel version with the uname -r command

2. Log in to Centos as user root. Make sure the YUM package is up to date. sudo yum update

Sudo yum remove docker docker-common docker-selinux docker-engine

Yum-util provides yum-config-manager functionality. Y y yum install device-utils device-mapper-persistent-data LVM2

5, set the yum source sudo yum – config – manager – add – ‘https://download.docker.com/linux/centos/docker-ce.repo

6, you can view all all docker version in the warehouse, and select a specific version installed yum list docker – ce – showduplicates | sort – r

18.06.3 sudo yum install docker-ce-18.06.3.ce-3.el7 安装docker sudo yum install docker-ce 安装 docker-ce-18.06.3.ce-3.el7 安装docker sudo yum install docker-ce

Sudo systemctl start docker sudo systemctl enable docker sudo systemctl enable docker sudo systemctl enable docker sudo systemctl enable docker

9, verify whether the installation is successful (there are two parts of docker installation and service are successful) Docker version

(3) Docker Ali mirror acceleration

Application address: cr.console.aliyun.com/cn-hangzhou…

3. Install Rancher-Server and manage Docker container with graphical interface

Docker run -d –restart=unless-stopped –name=myRancherServer -p 18001:8080 docker run -d –restart=unless-stopped –name=myRancherServer -p 18001:8080 The rancher/server: v1.6.26

2, open the rancher’s address, 119.3.230.111 this host IP 18001 is a rancher himself exposed in the port of http://119.3.230.111:18001/

Use of rancher

(1) Add a host

1. Click Add Host, add the server host through Rancher, deploy the container in the host through Rancher, and set the scheduling rules of the container by adding host labels through Rancher to achieve load balancing.

2. Copy the public IP address of the server (copy the IP address of each server to be added) to Step 4 and run the command in Step 5 on the corresponding server. Then close the command and you can see that the host is added and initialized.

3. After hosts are added, host labels can be added to facilitate load balancing for subsequent containers.

(2) Add applications

1. Click Add App

2. Import the two configuration files to migrate an application that has been created. Otherwise, click Create

3. Add services and configure mirroring

4. The scheduling rule for adding hosts to containers implements load balancing for containers, corresponding to the host labels previously configured

5. Click Add Load Balancing to configure load balancing

6. Port 19005 is exposed for user access

7. Application export configuration. The configuration files of the exported application are docker-comemage. yml and Rancher-comemage. yml is convenient for application migration or quick application import when rancher container fails unexpectedly.

8. The screenshot of the application is as follows

9. The load balancer deployed on the host is as follows

Docker common commands

1, View all containers docker PS running

Docker ps -a = docker ps -a

CONTAINER ID docker ps – aq

Docker stop 5a651177e0c5 // 00FE9a6e1b50 is the CONTAINER ID

Docker stop $(docker ps — aq)

Docker rm 5A651177e0C5 // 00FE9a6e1B50 is the ID of the CONTAINER

Docker rm $(docker ps — aq)

8. View docker images

Docker images-aq = docker images-aq = docker images-aq

Docker rmi 00FE9a6e1b50 // 00FE9a6e1b50 is the IMAGE ID

Docker images-aq $(docker images-aq)

Docker — help