#!/bin/bash
install_docker(){
#更新 yum 包
sudo yum update -y
#装置依赖
sudo yum install -y yum-utils device-mapper-persistent-data lvm2
#设置 yum 源
sudo yum-config-manager --add-repo http://mirrors.aliyun.com/docker-ce/linux/centos/docker-ce.repo
#装置 docker
sudo yum install docker-ce -y;
#版本查看
docker -v;
#配置镜像减速
mkdir -p /etc/docker;
cd /etc/docker;
cat > daemon.json <<EOF
{"registry-mirrors": ["https://docker.mirrors.ustc.edu.cn"]
}
EOF
#重新启动服务
systemctl daemon-reload;
systemctl restart docker;
#查看减速是否失效
docker info;
#启动 docker 并设置开机自启动
systemctl enable docker
systemctl start docker
systemctl status docker
docker ps -a
}
install_docker