1. Environment
- Linux version: CentOS Linux release 7.3.1611 (Core)
- The network is unblocked (you can access Baidu)
2. Uninstall the old version of docker
yum remove docker \
docker-client \
docker-client-latest \
docker-common \
docker-latest \
docker-latest-logrotate \
docker-logrotate \
docker-engine
3. Install gcc
gcc -v
yum -y install gcc
yum -y install gcc-c++
4. Install the yum-utils package
yum install -y yum-utils
5. Set up a stable repository
- It is recommended to use Alibaba Cloud's mirror library
yum-config-manager \
--add-repo \
https://mirrors.aliyun.com/docker-ce/linux/centos/docker-ce.repo
6. Update yum package index
yum makecache fast
7. Install the latest version of Docker Engine and container
yum -y install docker-ce docker-ce-cli containerd.io
8. Start Docker
systemctl start docker
docker version
docker run hello-world
docker images
9. Configure Mirror Acceleration
mkdir -p /etc/docker
vim /etc/docker/daemon.json
{
"registry-mirrors": ["https://自己的编码.mirror.aliyuncs.com"]
}
systemctl daemon-reload
systemctl restart docker
ps -ef | grep docker
10. Uninstall docker
systemctl stop docker
yum -y docker-ce docker-ce-cli containerd.io
rm -rf /var/lib/docker
- Docker official documentation: https://docs.docker.com/engine/install/centos/
- Aliyun official website: https://cn.aliyun.com/