Docker installation

The installation

Environment to prepare

1.Linux server Centos7

2. Remote connection

Environment view

The kernel is above 3.10
[root@VM-0-11-centos ~]# uname -r3.10.0-1127.19.1. El7. X86_64Copy the code
# System details
NAME="CentOS Linux"
VERSION="7 (Core)"
ID="centos"
ID_LIKE="rhel fedora"
VERSION_ID="Seven"
PRETTY_NAME="CentOS Linux 7 (Core)"
ANSI_COLOR="0; 31"
CPE_NAME="cpe:/o:centos:centos:7"
HOME_URL="https://www.centos.org/"
BUG_REPORT_URL="https://bugs.centos.org/"

CENTOS_MANTISBT_PROJECT="CentOS-7"
CENTOS_MANTISBT_PROJECT_VERSION="Seven"
REDHAT_SUPPORT_PRODUCT="centos"
REDHAT_SUPPORT_PRODUCT_VERSION="Seven"
Copy the code

The installation

Help documents:

#1. Uninstall the old files
yum remove docker \
                  docker-client \
                  docker-client-latest \
                  docker-common \
                  docker-latest \
                  docker-latest-logrotate \
                  docker-logrotate \
                  docker-engine
                  
#2. Required installation package
yum install -y yum-utils

#3. Set the repository for the imageYum - config - manager \ - add - yum repo \ https://download.docker.com/linux/centos/docker-ce.repo # default abroad - config - manager \ - add - repo \ http://mirrors.aliyun.com/docker-ce/linux/centos/docker-ce.repo # is recommended to use ali cloud#Update yum Index
yum makecache fast

#4, install docker Docker-CE community edition
yum install docker-ce docker-ce-cli containerd.io

#5. Start Docker
systemctl start docker

#6. Use docker Version to check whether the installation is successful

Copy the code

#7, the run
docker run hello-world
Copy the code

# 8, View the downloaded Hello-word image
docker images
Copy the code

#9, unloading
#Unload rely on
yum remove docker-ce docker-ce-cli containerd.io

#Delete the resource
rm -rf /var/lib/docker
rm -rf /var/lib/containerd
Copy the code

Ali Cloud image acceleration

1. Log in to Ali Cloud container image service

2. Locate the system in the lower left corner of the acceleration address of the mirroring service

3, configuration,

sudo mkdir -p /etc/docker

sudo tee /etc/docker/daemon.json <<-'EOF'
{
  "registry-mirrors": ["https://ki5mdt9h.mirror.aliyuncs.com"]
}
EOF

sudo systemctl daemon-reload

sudo systemctl restart docker
Copy the code

Review process

1. Start

2.Docker will look for images on the machine

3. Check whether the local host is mirrored

4. Run if there is no mirror, go to the warehouse to download

5. Download it and run it

The underlying principle

How does Docker work?

Docker is a Client Server structure of the system, Docker daemon running on the host. Access from client through Socket!

When Docker Server receives the docker-client command, it executes this command!

Why is Docker faster than Vm?

1. Docker has fewer abstraction layers than virtual machines

2. Docker uses the kernel of the host computer

Therefore, when creating a container, Docker does not need to reload an operating system kernel like a virtual machine to avoid booting.

Virtual machines load GuestOS at the minute level, while Docker uses the host operating system, omits this complicated process, at the second level!

Centos8 installation docker

yum erase podman buildah
yum install docker-ce docker-ce-cli containerd.io
systemctl start docker
systemctl enable docker
Copy the code