CentOS7(最小安装版)安装Docker
简介
来源1:https://yeasy.gitbooks.io/docker_practice/content/install/centos.html
来源2:https://yeasy.gitbooks.io/docker_practice/content/install/mirror.html
来源3:https://www.cnblogs.com/xuezhigu/p/6553936.html
推荐阅读:https://yeasy.gitbooks.io/docker_practice/content/
使用版本
- CentOS7 :最小安装版:http://isoredirect.centos.org/centos/7/isos/x86_64/CentOS-7-x86_64-Minimal-1810.iso
- Docker: Docker CE 的 Edge 版本
1.卸载原来版本
- 查询安装过的包:
命令:yum list installed | grep docker
结果:docker-engine.x86_64 17.03.0.ce-1.el7.centos @dockerrepo
- 删除安装的软件包
命令:yum -y remove docker-engine.x86_64
说明:docker-engine.x86_64 来源于上一步 - 删除镜像/容器等
命令:rm -rf /var/lib/docker
- 官网删除法
命令:
sudo yum remove docker \
docker-client \
docker-client-latest \
docker-common \
docker-latest \
docker-latest-logrotate \
docker-logrotate \
docker-selinux \
docker-engine-selinux \
docker-engine
2.使用脚本自动安装
- 下载脚本:
curl -fsSL get.docker.com -o get-docker.sh
- 运行脚本:
sudo sh get-docker.sh --mirror Aliyun
3.启动Docker
- 启用:
sudo systemctl enable docker
- 启动:
sudo systemctl start docker
4.测试Docker
- 测试:
docker run hello-world
- 结果:
Unable to find image 'hello-world:latest' locally
latest: Pulling from library/hello-world
d1725b59e92d: Pull complete
Digest: sha256:0add3ace90ecb4adbf7777e9aacf18357296e799f81cabc9fde470971e499788
Status: Downloaded newer image for hello-world:latest
Hello from Docker!
This message shows that your installation appears to be working correctly.
。。。。。。。。。。
5.使用镜像加速
- 打开配置文件:
vi /etc/docker/daemon.json
- 输入并保存:
{
"registry-mirrors": [
"https://dockerhub.azk8s.cn",
"https://reg-mirror.qiniu.com"
]
}
- 重启daemon:
sudo systemctl daemon-reload
- 重启Docker:
sudo systemctl restart docker
- 测试命令:
docker info
- 测试结果包含:
Registry Mirrors: https://dockerhub.azk8s.cn/