Docker installation, startup, accelerator in Aliyun CentOS environment (14)

Docker installation, startup, accelerator in Aliyun CentOS environment (14)

introduce

Since version 1.13, Docker has adopted the timeline method as the version number, which is divided into community version CE and enterprise version EE.
The community edition is free for individual developers and small groups, and the enterprise edition provides additional paid services, such as officially tested and certified infrastructure, containers, plug-ins, etc.

Docker is a package of Linux containers that provides an easy-to-use container interface. It is currently the most popular Linux container solution.
Docker packages the application and the program's dependencies in a single file. Running this file will generate a virtual container. Programs run in this virtual container as if they were running on a real physical machine. With Docker, you don't have to worry about the environment.
Overall, Docker's interface is quite simple, and users can easily create and use containers, and put their own applications into containers. Containers can also be versioned, copied, shared, and modified, just like normal code.

The following 一些概念helps to understand docker :
1. Docker images (Images): Docker images are templates for creating Docker containers.
2. Docker container (Container): A container is an application or a group of applications that run independently.
3. Docker Client (Client): The Docker client communicates with the Docker daemon through the command line or other tools using the Docker API ( https://docs.docker.com/reference/api/docker_remote_api ).
4. Docker host (Host): A physical or virtual machine used to execute Docker daemons and containers.
5. Docker warehouse (Registry): Docker warehouse is used to save images, which can be understood as a code warehouse in code control.
6. Docker Hub ( https://hub.docker.com ): Provides a huge collection of images for use.
7. Docker Machine: Docker Machine is a command-line tool that simplifies Docker installation. Docker can be installed on the corresponding platform through a simple command line, such as VirtualBox, Digital Ocean, Microsoft Azure.


Preconditions

1.64-bit version of CentOS 7. Command lsb_release -a
2. The kernel version of the CentOS system is higher than 3.10. Orderuname -r


Install

1. Uninstall (optional)

The old version of Docker is called docker or docker-engine. If it was installed before, the uninstall command is as follows:

yum remove docker docker-common container-selinux docker-selinux docker-engine

Some articles used here yum upgrade, the command is meant to be 升级所有包同时也升级软件和系统内核. I suggest that it is best not to execute the command, and the system may crash because the system version is upgraded from low-level to high-level, and some software may have problems.

2. Install the yum-utils device-mapper-persistent-data lvm2 package

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

3. Configure the stable version library

Most users set up and install from Docker's repositories to facilitate installation and upgrade tasks. This is the recommended method

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

4. View all docker versions in all repositories

See all community editions of docker-ce.

yum list docker-ce --showduplicates | sort -r

write picture description here
1. Only the stable warehouse is enabled by default in the repo, so all 稳定版本the dockers shown here are.
2. Use the sort -r command to sort the results with version numbers from highest to lowest and truncated.
3. The first column is the software name, the second column is the version string, and the third column is the repository name, use the specified version to install包名-第二列是版本字符串

5. Install docker

Install the specified version as follows:

yum install docker-ce-18.03.1.ce-1.el7.centos

The latest version

yum install docker-ce

Since only the stable warehouse is enabled by default in the repo, the latest stable version 18.03 is installed here.

6. Start docker

start command

systemctl start docker

View version

docker -version

docker start/restart/stop commands

Add docker startup: systemctl enable docker
start command: systemctl start docker
restart command: systemctl restart docker
stop command: systemctl stop docker
view version: docker version
uninstall: yum remove docker-ce
view window port mapping: docker ps
other docker command parameters here


Configure the accelerator

Due to the slow access to the official mirror address, I have to configure a domestic mirror. I use Alibaba Cloud's accelerator here. After all, I use Alibaba Cloud's ECS, mysql, and redis, so my accelerator also uses it, which is my personal choice.
Log in to Alibaba Cloud-Developer Platform , and the Alibaba Cloud console account is a common account. If the login is successful, select the 镜像加速器tab in the middle on the left, and the result is as follows:
write picture description here
Configure the Docker accelerator on the CentOS system according to the schematic method:

vi /etc/docker/daemon.json

Modify the file as follows

{
  "registry-mirrors": ["https://l8ue6x6v.mirror.aliyuncs.com"]
}

Here are several other accelerators, just replace the above address
NetEase accelerator: http://hub-mirror.c.163.com
Official Chinese accelerator: https://registry.docker-cn.com
Mirror of ustc: https://docker.mirrors.ustc.edu.cn
daocloud: https://www.daocloud.io/mirror#accelerator-doc (used after registration)

Reload configuration, restart docker

systemctl daemon-reload
systemctl restart docker

Test accelerator effect
Extract image

docker pull busybox

If "hello world" is successfully printed out, the Alibaba Cloud accelerator is successfully configured.

docker run busybox echo “hello world” 

Guess you like

Origin http://43.154.161.224:23101/article/api/json?id=325370461&siteId=291194637