D002-docker安装及卸载
实验环境:
CentOS 7
1.卸载旧的docker
yum remove docker \ docker-client \ docker-client-lastest \ docker-common \ docker-lastest \ docker-lastest-logrotate \ docker-logrotate \ docker-engine
2.安装必要在yum包
yum install -y yum-utils
3.设置镜像的仓库
yum-config-manager --add-repo http://mirrors.aliyun.com/docker-ce/linux/centos/docker-ce.repo yum makecache fast
4.安装docker相关的组件
yum install docker-ce
5.启动docker
systemctl start docker
6.使用docker version确定是否安装成功
7.运行hello-world镜像
docker run hello-world
8.运行hello-world镜像报错的修复方法
![](https://images.cnblogs.com/OutliningIndicators/ContractedBlock.gif)
docker run hello-world docker: Error response from daemon: Get https://registry-1.docker.io/v2/: net/http: request canceled while waiting for connection (Client.Timeout exceeded while awaiting headers). See 'docker run --help'. 修改docker镜像源: docker默认的源为国外官方源,下载速度较慢,可改为国内,加速 方案一: 修改或新增 /etc/docker/daemon.json # vi /etc/docker/daemon.json { "registry-mirrors": ["http://hub-mirror.c.163.com"] } systemctl restart docker.service 方案二: 修改或新增 /etc/sysconfig/docker,在OPTIONS变量后追加参数 --registry-mirror=https://docker.mirrors.ustc.edu.cn # vi /etc/sysconfig/docker OPTIONS='--selinux-enabled --log-driver=journald --registry-mirror=https://docker.mirrors.ustc.edu.cn' Docker国内源说明: Docker 官方中国区 https://registry.docker-cn.com 网易 http://hub-mirror.c.163.com 中国科技大学 https://docker.mirrors.ustc.edu.cn 阿里云 https://pee6w651.mirror.aliyuncs.com
9.查看hello-world镜像
docker images
10.卸载docker
yum remove docker-ce rm -rf /var/lib/docker