自动安装docker

使用shell命令编写的自动化安装docker
# 使用vi 命令创建一个文件
vi install_docker
#下面是该文件内容直接复制进去
#!/bin/bash
rpm -qa|grep docker > /dev/null
if [ $? -eq 0 ]
then
  echo " docker already install ...."
  exit
fi
echo “======================  Start Docker Install  ==================”
yum install -y yum-utils
yum-config-manager --add-repo https://mirrors.aliyun.com/docker-ce/linux/centos/docker-ce.repo
yum install -y docker-ce docker-ce-cli containerd.io docker-buildx-plugin docker-compose-plugin
mkdir -p /opt/docker
cat > /etc/docker/daemon.json << EOF
{
"registry-mirrors":["https://hub-mirror.c.163.com","https://registry.aliyuncs.com","https://docker.mirrors.ustc.edu.cn"],
"log-driver": "json-file",
"log-opts": {
     "max-size": "10m",
     "max-file": "5"
 },
 "data-root":"/opt/docker"
}
EOF
systemctl enable --now docker
echo -e "\033[32m ============== Docker Install Successfully!!!  ==================\033[0m"
#执行该脚本方式
bash install_docker

你可能感兴趣的:(shell,shell,shell编程)