-
确定你是CentOS7以及以上的版本:cat /etc/redhat-release
-
yum安装gcc相关:
- 安装gcc:yum -y install gcc
- 安装gcc-c++:yum -y install gcc-c++
- 验证安装成功:gcc -v
-
卸载旧版本: yum remove docker docker-client docker-client-latest docker-common docker-latest docker-latest-logrotate docker-logrotate docker-engine
-
安装需要的软件包:yum install -y yum-utils device-mapper-persistent-data lvm2
-
设置stable镜像仓库:
- 官网方法:yum-config-manager --add-repo download.docker.com/linux/cento…
- (推荐)阿里云:yum-config-manager --add-repo mirrors.aliyun.com/docker-ce/l…
- 建议:使用阿里云的方法,因为官网很慢,容易报错
-
更新yum软件包索引:yum makecache fast
-
安装Docker CE:yum -y install docker-ce
-
启动docker:systemctl start docker
-
测试:
- 查看版本:docker version
- hello-world:docker run hello-world
-
配置镜像加速:
- mkdir -p /etc/docker
- vim /etc/docker/daemon.json
- #阿里云{ "registry-mirrors": ["https://{自已的编码}.mirror.aliyuncs.com"]}
- systemctl daemon-reload
- systemctl restart docker
-
卸载:
- systemctl stop docker
- yum -y remove docker-ce
- rm -rf /var/lib/docker