官网
Install Docker Engine on CentOS | Docker Docs
yum -y install gcc
yum -y install gcc-c++
安装工具
sudo yum install -y yum-utils
设置国内的镜像
yum-config-manager \
--add-repo \
https://mirrors.aliyun.com/docker-ce/linux/centos/docker-ce.repo
yum makecache fast
安装
yum install docker-ce docker-ce-cli containerd.io
systemctl start docker # 启动docker服务
systemctl stop docker # 停止docker服务
systemctl restart docker # 重启docker服务
卸载
sudo rm -rf /var/lib/docker
sudo rm -rf /var/lib/containerd
设置镜像加速器,我这里配置的是阿里云
sudo mkdir -p /etc/docker
sudo tee /etc/docker/daemon.json <<-'EOF'
{
"registry-mirrors": ["https://bwahx39XXXX.mirror.aliyuncs.com"]
}
EOF
sudo systemctl daemon-reload
sudo systemctl restart docker
docker run hello-world
到这里就是说明成功啦!
# 关闭
systemctl stop firewalld
# 禁止开机启动防火墙
systemctl disable firewalld