说了那么多docker的知识,是时候更新docker的安装了
我们使用的是 CentOS 7 (64-bit)目前, CentOS 仅发行版本中的内核支持 Docker 。Docker 运行在 CentOS 7 上,要求系统为 64 位、系统内核版本为 3.10 以上。
1、官网安装参考手册:https://docs.docker.com/engine/install/centos/
2、确定你是CentOS7及以上版本
3、yum安装gcc相关环境(需要确保 虚拟机可以上外网 )
yum -y install gcc
yum -y install gcc-c++
4、卸载旧版本(如果之前没安装过则不需要)
yum remove docker \
docker-client \
docker-client-latest \
docker-common \
docker-latest \
docker-latest-logrotate \
docker-logrotate \
docker-engine
5、安装需要的软件包
yum install -y yum-utils
6、设置镜像仓库
# 错误 yum-config-manager --add-repo
https://download.docker.com/linux/centos/docker-ce.repo
## 报错 [Errno 14] curl#35 - TCP connection reset by peer [Errno 12] curl#35 - Timeout
# 正确推荐使用国内的 yum-config-manager --add-repo http://mirrors.aliyun.com/docker- ce/linux/centos/docker-ce.repo
7、更新yum软件包索引
yum makecache fast
8、安装 Docker CE
yum install docker-ce docker-ce-cli containerd.io
9、启动 Docker
systemctl start docker
10、测试命令
docker version
docker run hello-world
docker images
恭喜,如果你见到如下的图,则说明安装成功
11、卸载
systemctl stop docker
yum -y remove docker-ce docker-ce-cli containerd.io
rm -rf /var/lib/docker