Docker官网:http://www.docker.com
Docker Hub仓库官网: https://hub.docker.com/
CentOS 7 (64-bit)
CentOS 6.5 (64-bit) 或更高的版本
查看自己的内核uname命令用于打印当前系统相关信息(内核版本号、硬件架构、主机名称和操作系统类型等)。
uname -r
cat /etc/redhat-release
可以参考官方文档:https://docs.docker.com/install/linux/docker-ce/centos/
官网中文安装手册:https://docs.docker-cn.com/engine/installation/linux/docker-ce/centos/#prerequisites
yum -y remove docker \docker-client \docker-client-latest \docker-common \docker-latest \docker-latest-logrotate \docker-logrotate \docker-engine
yum -y install gcc
yum -y install gcc-c++
yum install -y yum-utils device-mapper-persistent-data lvm2
yum-config-manager --add-repo http://mirrors.aliyun.com/docker-ce/linux/centos/docker-ce.repo
注意:这里不要使用官方仓库,使用阿里仓库,否则后续yum安装可能报错。
1 [Errno 14] curl#35 - TCP connection reset by peer
2 [Errno 12] curl#35 - Timeou
yum makecache fast
yum -y install docker-ce
如果报错,重新执行安装一次
systemctl start docker
启动报错找不到,将上一个命令再执行一次
docker version
或者 直接运行镜像 hello-world (运行流程如下图所示)
docker run hello-world
9. 卸载
systemctl stop docker
yum -y remove docker-ce
rm -rf /var/lib/docker
鉴于国内网络问题,后续拉取 Docker 镜像十分缓慢,我们可以需要配置加速器来解决:
- 阿里云镜像
- 网易镜像
官网地址:https://www.aliyun.com/
登陆阿里云开发者平台,找到“容器镜像服务”
镜像加速器地址,每个人都不一样,拷贝加速器地址
mkdir -p /etc/docker
vim /etc/docker/daemon.json
{
"registry-mirrors": ["https://vot7qvzq.mirror.aliyuncs.com","http://hub-mirror.c.163.com"]
}
systemctl daemon-reload
systemctl restart docker
查看服务状态:能正常启动,说明配置成功了
systemctl status docker
如果运行失败,执行dockerd命令查看错误