CentOS7安装Docker
1、确定你是CentOS7及以上版本
cat /etc/redhat-release
2、确保CentOS7的PIC以太网已连接
3、yum安装gcc相关
yum -y install gcc
4、卸载旧版本(如果有)
yum -y remove docker docker-common docker-selinux docker-engine
2018.3官网版本:
yum remove docker \
docker-client \
docker-client-latest \
docker-common \
docker-latest \
docker-latest-logrotate \
docker-logrotate \
docker-selinux \
docker-engine-selinux \
docker-engine
5、安装需要的软件包
yum install -y yum-utils device-mapper-persistent-data lvm2
6、设置stable镜像仓库
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 -y install docker-ce
9、启动docker
systemctl start docker
10、测试
docker version
docker run hello-world
11、配置镜像加速
vim /etc/docker/daemon.json
#网易云
{"registry-mirrors": ["http://hub-mirror.c.163.com"]?}
#阿里云
{
"registry-mirrors": ["https://{自已的编码}.mirror.aliyuncs.com"]
}
systemctl daemon-reload
systemctl restart docker
12、卸载Docker(需要时)
systemctl stop docker
yum -y remove docker-ce
rm -rf /var/lib/docker
13、遇到的问题
Job for docker.service failed because the control process exited with error code. See "systemctl status docker.service" and "journalctl -xe" for details.
........解决方法:
把yum包更新到最新
sudo yum update