linux centos7安装docker脚本

#!/bin/sh

#centos7安装docker脚本

 

# ExecStart=/usr/bin/dockerd --iptables=false -H fd:// --containerd=/run/containerd/containerd.sock


### 1安装依赖
yum install -y yum-utils device-mapper-persistent-data lvm2
if [ $? -eq 0 ]
then
echo -e "\033[32m '>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>> 1安装依赖 finish >>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>' \033[0m"
else
echo -e "\033[31m '__________________________________ 1安装依赖 bad ,and EXIT' \033[0m"
exit 1
fi

### 2设置yum源
yum-config-manager --add-repo https://download.docker.com/linux/centos/docker-ce.repo
if [ $? -eq 0 ]
then
echo -e "\033[32m '>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>> 2设置yum源 finish >>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>' \033[0m"
else
echo -e "\033[31m '__________________________________ 2设置yum源 bad ,and EXIT' \033[0m"
exit 1
fi

### 3安装最新版本的Docker CE和containerd
yum install -y docker-ce docker-ce-cli containerd.io
if [ $? -eq 0 ]
then
echo -e "\033[32m '>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>> 3安装最新版本 finish >>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>' \033[0m"
else
echo -e "\033[31m '__________________________________ 3安装最新版本的Docker CE和containerdbad ,and EXIT' \033[0m"
exit 1
fi

### 加入开机启动
systemctl enable docker

### 4修改docker防火墙权限,禁止docker操作防火墙,
### 一般情况下不需要禁用,所有注释
#sed -i 's/dockerd/dockerd --iptables=false/' /usr/lib/systemd/system/docker.service
#if [ $? -eq 0 ]
# then
# echo -e "\033[32m '>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>> 4修改docker防火墙权限 finish >>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>' \033[0m"
# else
# echo -e "\033[31m '__________________________________ 4修改docker防火墙权限 bad ,and EXIT' \033[0m"
# exit 1
#fi

###
systemctl daemon-reload
systemctl restart docker


echo -e "\033[32m '>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>> centos7 install docker ok >>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>' \033[0m"

posted @ 2022-02-24 14:46  tangshow  阅读(147)  评论(0编辑  收藏  举报