Rancher and Docker Quick Start Guide (1)-Alibaba Cloud Developer Community

Rancher is an open-source enterprise-level full-stack container deployment and management platform. Currently, we use the stable version V1.6 (released in 2017). Rancher2.0 was also released in 2018, rancher 2.0 is a product that simplifies and accelerates the implementation of enterprise Kubernetes(K8S). Due to the large changes in version 2.0, it is not convenient for us to get started with applications, A reliable and easy-to-install container version is not available. The following are the terminology changes of the two versions. 1.6 conforms to the terminology understanding of Docker. 2.0 has completely relied on professional K8S:

introduction to the Manual Guide (divided into one, two and three periods)

  • prerequisites
  • mounting Rancher
  • add and manage hosts
  • add and manage containers
  • add and manage applications
  • image Library application

let's share the architecture of the Rancher platform:

Docker must be installed on the hosts that install Rancher and other hosts that need to deploy Docker:

1. For CantOS, it is best to install Docker in CentOS7. This ensures that the kernel is at least 3.10 (check by using the uname -r command). Docker cannot be installed in kernels earlier than this version.

2. Log on to Centos with the root permission. Make sure that the yum package is updated to the latest (sudo yumupdate), and the CentOS7 machine of the company can not be updated.

3. Uninstall the old version (if the old version has been installed)

sudo yum remove docker docker-common docker-selinux docker-engine

4. Install the required software package. yum-util provides the yum-config-manager function, and the other two are dependent on the devicemapper driver.

sudo yum install -y yum-utils device-mapper-persistent-data lvm2

5. Set the yum source

sudo yum-config-manager --add-repo https://download.docker.com/linux/centos/docker-ce.repo

6. Install the latest version of docker directly (remember that the version would rather be the latest than the version required by the Rancher)

sudo yum install docker-ce

7. Start and add the boot startup

sudo systemctl start docker

sudo systemctl enable docker

8. You can accelerate the image. The official acceleration address in China is as follows: registry.docker-cn.com

echo'{"registry-mirrors": ["https://registry.docker-cn.com"]}'> /etc/docker/daemon.json

chinese official can only download public images, you have to go to the United States for private images, and provide another daocloud address online

echo'{"registry-mirrors": ["http://bcfb7352.m.daocloud.io"]}'> /etc/docker/daemon.json

there are a lot of images on the Internet, including the cloud addresses provided by Alibaba. However, these are not necessary for us at present. I don't think it is slow, so I can skip this step.

Note: If you cannot download docker-ce from the preceding default docker source, try using the Alibaba Cloud Source:

# Step 1: 添加软件源信息
sudo yum-config-manager --add-repo http://mirrors.aliyun.com/docker-ce/linux/centos/docker-ce.repo
# Step 2: 更新并安装 Docker-CE
sudo yum makecache fast
sudo yum -y install docker-ce
# Step 3: 开启Docker服务
sudo service docker start

Rancher is also a container, so we install the container:

sudo docker run -d --restart=unless-stopped -p 8080:8080 rancher/server

the rancher/server image pulls the latest version of Rancher V1.6.

The above is the official installation command. I think there is a problem with this installation. If you need to upgrade the Rancher or reinstall the container due to a fault, the historical data of our management platform will be lost. Therefore, we need to use volumes to map library files to local hosts. You need to create three local directories (mkdir -p):




use chmod -R 777 /opt/rancher to grant the highest permission, and then run the following command to install it:

sudo docker run -d --restart=unless-stopped -p 8080:8080 -v /opt/rancher/lib/cattle:/var/lib/cattle -v /opt/rancher/lib/mysql:/var/lib/mysql -v /opt/rancher/log/mysql:/var/log/mysql rancher/server

the preceding command ensures the reliability of the container. Not only does the container restart synchronously with the host, but after the Rancher is damaged or deleted, you only need to re-run the preceding command to rebuild the container. All the original management data is retained.

If you want to access Rancher mysql, you can map Port 3306 to the public when creating it.

After the Rancher is installed, access it directly through http:// IP:8080

to manage each node server through Rancher, you need to deploy the rancher-agent container on each host. By adding a host on the Rancher interface, you can easily generate relevant commands, in addition, rancher-agent is deployed, and various network services and monitoring services are deployed together.

1. Click infrastructure> hosts> add hosts. Select Custom

2. Add tags (multiple tags can be added): for example, add host.ip = the IP address of the host to be deployed

(Generally, tags can not be added, but in order to facilitate the deployment of cluster applications, docker-compose.yml files can be labeled with hosts of different nodes, or host.ip tag, tags can also be appended later).

Copy the command in step 5 on the interface

note: If the host is also deployed Rancher, you must enter the IP address of the host in step 4 of the figure.

3. Paste the copied command to the corresponding host for execution to complete the rancher-agent installation:

4. After the installation, close the current interface and return to the host management page to view the newly added host panel.

After the installation, the hostname is localhost (determined by the hostname). To facilitate identification, you can edit the hostname and customize a name, for example,


5. Manage hosts

as shown in the preceding panel, you can disable the host (you can delete the host only after it is disabled. The deletion here refers to removing management containers such as rancher-agent), evacuate (that is, clear all non-system containers managed by the host), edit (to implement memory, CPU configuration, tag settings, etc.), and add independent containers.


Please read this disclaimer carefully before you start to use the service. By using the service, you acknowledge that you have agreed to and accepted the content of this disclaimer in full. You may choose not to use the service if you do not agree to this disclaimer. This document is automatically generated based on public content on the Internet captured by Machine Learning Platform for AI. The copyright of the information in this document, such as web pages, images, and data, belongs to their respective author and publisher. Such automatically generated content does not reflect the views or opinions of Alibaba Cloud. It is your responsibility to determine the legality, accuracy, authenticity, practicality, and completeness of the content. We recommend that you consult a professional if you have any doubt in this regard. Alibaba Cloud accepts no responsibility for any consequences on account of your use of the content without verification. If you have feedback or you find that this document uses some content in which you have rights and interests, please contact us through this link: https://www.alibabacloud.com/campaign/contact-us-feedback. We will handle the matter according to relevant regulations.
Selected, One-Stop Store for Enterprise Applications
Support various scenarios to meet companies' needs at different stages of development

Start Building Today with a Free Trial to 50+ Products

Learn and experience the power of Alibaba Cloud.

Sign Up Now