1. Ensure that the version is CentOS 7 or later
cat /etc/redhat-release
Copy the code
Yum install GCC
yum -y install gcc
yum -y install gcc-c++
Copy the code
3. Uninstall the earlier version
yum remove docker \
docker-client \
docker-client-latest \
docker-common \
docker-latest \
docker-latest-logrotate \
docker-logrotate \
docker-engine
Copy the code
4. Install required software packages
yum install -y yum-utils
Copy the code
5. Set a stable mirror vault
Yum -config-manager --add-repo HTTPS://download.docker.com/linux/centos/docker-ce.repoYum-config-manager --add-repo HTTPS://mirrors.aliyun.com/docker-ce/linux/centos/docker-ce.repo(Both commands are ok, but aliyun is recommended, because the speed is faster in China!)Copy the code
You can use the following command to view the configuration:
cat /etc/yum.repos.d/docker-ce.repo
Copy the code
Here are some screenshots:
6. Update the yum software package index
yum makecache fast
Copy the code
7. Install the Docker CE
yum -y install docker-ce
Copy the code
(Note: this is because I have installed it once, so the prompt already exists and is the latest version. This should take about 2 minutes if you are doing it for the first time.
8. To start the docker
systemctl start docker
Copy the code
9. The test
docker version
Copy the code
docker run hello-world
Copy the code
This step may wait a little bit, as you need to go to Ali Cloud to download the latest. It will come up laterHello from Docker!
了
docker images
Copy the code
10. Configure mirror acceleration
10.1 mkdir -p /etc/docker
10.2 In the Configuration Filevim /etc/docker/dameon.json
To add the following content
10.3 Reloading the Daemon File:systemctl daemon-reload
10.4 Restarting Docker and Checking the Startup Status:
systemctl restart docker
ps -ef|grep docker|grep -v grep
Copy the code
11. Uninstall
systemctl stop docker
yum -y remove docker-ce
rm -rf /var/lib/docker
Copy the code
Attachment: Docker official website