View the centos kernel version
[root@VM-24-14-centos ~]# cat /etc/redhat-release
CentOS Linux release 7.9.2009 (Core)
Copy the code
CentOS 7 (yum)
Lvm2 # step 2: y y y y y y y y y y y y y y y y y Add software source information sudo yum - config - manager - add - 'http://mirrors.aliyun.com/docker-ce/linux/centos/docker-ce.repo # Step 3: Install docker-ce sudo yum makecache fast sudo yum -y install docker-ce # Step 4: Docker sudo service Docker start Note: Other notes in the comments below # Official Software source enables the latest software by default. You can obtain each version of the software package by editing the software source. For example, if the official test version of the software source is not available, you can use the following methods to enable. In the same way, various test versions can be opened. Docker-ce. Repo # change the enabled=0 under [docker-ce-test] to enabled=1 # Find docker-CE version: # yum list docker-ce.x86_64 --showduplicates | sort -r # Loading mirror speeds from cached hostfile # Loaded plugins: branch, fastestmirror, Langpacks # docker-ce.x86_64 17.03.1. Ce-1.el7.centos docker-ce-stable # docker-ce.x86_64 17.03.1 @docker-ce-stable # docker-ce.x86_64 17.03.0.ce-1.el7. Centos docker-ce-stable # Available Packages # Step2: Install the specified version of docker-CE: # sudo yum -y install docker-ce-[VERSION] # sudo yum -y install docker-ce- After some versions, other dependencies appear in the docker-CE installation. If the installation fails, please pay attention to the error message. For example, after Docker-CE 17.03, you need to install docker-CE-selinux. # yum list docker-ce-selinux- --showduplicates | sort -r # sudo yum -y install docker-ce-selinux-[VERSION] # For the installation on a classic network or VPC network, replace Step 2 with the following command: # sudo yum - config - manager - add - 'http://mirrors.aliyuncs.com/docker-ce/linux/centos/docker-ce.repo # VPC network: # sudo yum-config-manager --add-repo http://mirrors.could.aliyuncs.com/docker-ce/linux/centos/docker-ce.repoCopy the code
Verify version installation: Docker version
[root@VM-24-14-centos ~]# docker version Client: Docker Engine - Community # Dea9396 Built: Thu Nov 18 00:38:53 2021 OS/Arch: Linux /amd64 Context: Default Experimental: true Server: Docker Engine - Community # 1.41 (minimum version 1.12) Go version: go1.16.9 Git commit: 847DA18 Built: Thu Nov 18 00:37:172021 OS/Arch: Linux/amd64 Experimental: false containerd: Version: 1.4.12 GitCommit: 7 b11cfaabd73bb80907dd23182b9347b4245eb5d runc: Version: 1.0.2 GitCommit: v1.0.2-0 -g52b36A2 Docker-init: Version: 0.19.0 GitCommit: de40ad0Copy the code
Query network information: IP addr
[root@VM-24-14-centos ~]# ip addr 1: lo: <LOOPBACK,UP,LOWER_UP> mtu 65536 qdisc noqueue state UNKNOWN group default qlen 1000 link/loopback 00:00:00:00:00:00 brd 00:00:00:00:00:00 inet 127.0.0.1/8 scope host LO valid_lft forever preferred_lft forever Inet6 ::1/128 scope host valid_lft forever preferred_lft forever 2: eth0: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1500 qdisc mq state UP group default qlen 1000 link/ether 52:54:00:0f:a8:71 brd Ff :ff:ff:ff:ff:ff :ff:ff inet 10.0.24.14/22 BRD 10.0.27.255 scope global eth0 valid_lft forever preferred_lft forever inet6 fe80::5054:ff:fe0f:a871/64 scope link valid_lft forever preferred_lft forever 3: docker0: "NO - CARRIER, BROADCAST, MULTICAST, UP > mtu 1500 qdisc noqueue state DOWN group default # docker0 virtual bridge link/Mr 02:42: EC: FC :73:db BRD FF :ff:ff:ff:ff inet 172.17.0.1/16 BRD 172.17.255.255 scope Global Docker0 VALID_lft forever preferred_lft foreverCopy the code
Set on start
See whether to join the boot startup systemctl list - unit - files | grep XXX [root @ VM - 24-14 - centos ~] # systemctl list - unit - files | grep docker Docker. service disabled Docker. socket disabled [root@VM-24-14-centos ~]# systemctl enable docker.service Created symlink from /etc/systemd/system/multi-user.target.wants/docker.service to / usr/lib/systemd/system/docker. Service. [root @ VM - 24-14 - centos ~] # systemctl status docker # check status low docker. Service - Docker Application Container Engine Loaded: loaded (/usr/lib/systemd/system/docker.service; enabled; vendor preset: disabled) Active: active (running) since Mon 2021-11-22 11:19:19 CST; 9min ago Docs: https://docs.docker.com Main PID: 14752 (dockerd) CGroup: / system. Slice/docker. Service └ ─ 14752 / usr/bin/dockerd -h fd: / / -- containerd = / run/containerd containerd. The sock Nov 22 11:19:19VM-24-14-centos Dockerd [14752]: time="2021-11-22T11:19:19.062613511+08:00" level=info MSG =" Scheme \" Unix \... e=grpc Nov 22 11:19:19 VM-24-14-centos dockerd[14752]: Time = ": the 2021-11-22 T11 used. 062630573 + 08:00" level = info MSG = "ccResolverWrap... e=grpc Nov 22 11:19:19 VM-24-14-centos dockerd[14752]: Time = ": the 2021-11-22 T11 used. 062640973 + 08:00" level = info MSG = "ClientConn swi... e=grpc Nov 22 11:19:19 VM-24-14-centos dockerd[14752]: Time = ": the 2021-11-22 T11 used. 112754837 + 08:00" level = info MSG = "Loading contai... tart." Nov 22 11:19:19 VM-24-14-centos dockerd[14752]: Time = ": the 2021-11-22 T11 used. 210498195 + 08:00" level = info MSG = "Default bridge... dress" Nov 22 11:19:19 VM-24-14-centos dockerd[14752]: Time = ": the 2021-11-22 T11 used. 246340397 + 08:00" level = info MSG = "Loading contai... done." Nov 22 11:19:19 VM-24-14-centos dockerd[14752]: Time = ": the 2021-11-22 T11 used. 272172619 + 08:00" level = info MSG = "daemon" Docker... 10.11 Nov 22 11:19:19 VM-24-14-centos Dockerd [14752]: Time ="2021-11-22T11:19:19.272271775+08:00" level=info MSG ="Daemon has com... ation" Nov 22 11:19:19 VM-24-14-centos systemd[1]: Started Docker Application Container Engine. Nov 22 11:19:19 VM-24-14-centos dockerd[14752]: Time ="2021-11-22T11:19:19.298526658+08:00" level=info MSG ="API listen on.... sock" Hint: Some lines were ellipsized, use -l to show in full.Copy the code
Docker run hello-world
[root@VM-24-14-centos ~]# docker run hello-world
Unable to find image 'hello-world:latest' locally
latest: Pulling from library/hello-world
2db29710123e: Pull complete
Digest: sha256:cc15c5b292d8525effc0f89cb299f1804f3a725c8d05e158653a563f15e4f685
Status: Downloaded newer image for hello-world:latest
Hello from Docker!
This message shows that your installation appears to be working correctly.
To generate this message, Docker took the following steps:
1. The Docker client contacted the Docker daemon.
2. The Docker daemon pulled the "hello-world" image from the Docker Hub.
(amd64)
3. The Docker daemon created a new container from that image which runs the
executable that produces the output you are currently reading.
4. The Docker daemon streamed that output to the Docker client, which sent it
to your terminal.
To try something more ambitious, you can run an Ubuntu container with:
$ docker run -it ubuntu bash
Share images, automate workflows, and more with a free Docker ID:
https://hub.docker.com/
For more examples and ideas, visit:
https://docs.docker.com/get-started/
Copy the code
Configuring Accelerated Mirroring
1. Install or upgrade the Docker client
Docker client 1.10.0 or later is recommended. For details, see Docker-CE
2. Configure the mirror accelerator
For users with Docker client version greater than 1.10.0
You can use the accelerator by modifying the daemon configuration file /etc/docker-daemon. json
# XXXX is replaced with its own acceleration address, acceleration page: https://cr.console.aliyun.com/cn-beijing/instances/mirrors sudo mkdir -p /etc/docker sudo tee /etc/docker/daemon.json <<-'EOF' { "registry-mirrors": ["https://xxxx.mirror.aliyuncs.com"] } EOF sudo systemctl daemon-reload sudo systemctl restart dockerCopy the code
Upgrade and uninstall Docker
# install yum install docker-ce # install yum install docker-ce or customized configuration files rm -rf /var/lib/dockerCopy the code