一、docker-18.03.1-ce.tar.gz
下载
安装
# !/bin/bash
# 一键部署Docker
# Create : 2019-12-13
# Update : 2019-12-13
# @Autor : wuduoqiang
# 要安装的软件名
software=docker
# 判断服务是否在运行
systemctl status $software &>/dev/null
if [ $? -eq 0 ];then
echo "$software在运行!"
exit
fi
# 判断命令是否存在
if $(command -v $software > /dev/null 2>&1);
then
echo "$software已经安装!"
$software -v
exit
fi
# 判断源码包是否安装过
if rpm -q $software &>/dev/null;
then
echo "$software已经安装!"
$software -v
exit
fi
# 开始安装服务
echo "解压$software程序!"
tar -zxvf docker-18.03.1-ce.tar.gz
echo "配置$software程序!"
sudo cp docker-18.03.1-ce/* /usr/bin/
sudo cp docker.service /etc/systemd/system/
echo "重新加载配置文件!"
systemctl daemon-reload
echo "启动$software服务!"
systemctl start $software
echo "添加开启自动启动!"
systemctl enable docker.service
echo "$software运行状态!"
systemctl status $software
echo "安装版本如下"
$software -v
sudo rm -rf docker.service docker-18.03.1-ce
卸载
# !/bin/bash
# 一键卸载Docker
# Create : 2019-12-13
# Update : 2019-12-13
# @Autor : wuduoqiang
# 要卸载的软件
software=docker
function undocker(){
echo "禁止启动"
systemctl enable docker.service
echo "停止服务"
systemctl stop $software
echo "移除文件"
cd /usr/bin/
sudo rm docker docker-containerd docker-containerd-ctr docker-containerd-shim dockerd docker-init docker-proxy docker-runc
cd /etc/systemd/system/
sudo rm docker.service
echo "卸载成功"
exit
}
# 判断服务是否在运行
systemctl status $software &>/dev/null
if [ $? -eq 0 ];then
undocker
else
echo "docker未安装!"
exit
fi
# 判断命令是否存在
if $(command -v $software > /dev/null 2>&1);
then
undocker
else
echo "docker未安装!"
exit
fi
# 判断源码包是否安装过
if rpm -q $software &>/dev/null;
then
undocker
else
echo "docker未安装!"
exit
fi
二、docker-18.06.1-ce.tar.gz
下载
安装
# !/bin/bash
# 一键部署Docker
# Create : 2019-12-13
# Update : 2019-12-13
# @Autor : wuduoqiang
# 要安装的软件名
software=docker
# 安装版本
version=docker-18.06.1-ce.tar.gz
# 解压后的目录名
folder=docker-18.06.1-ce
# 判断服务是否在运行
systemctl status $software &>/dev/null
if [ $? -eq 0 ];then
echo "$software在运行!"
exit
fi
# 判断命令是否存在
if $(command -v $software > /dev/null 2>&1);
then
echo "$software已经安装!"
$software -v
exit
fi
# 判断源码包是否安装过
if rpm -q $software &>/dev/null;
then
echo "$software已经安装!"
$software -v
exit
fi
# 开始安装服务
echo "解压$software程序!"
tar -zxvf $version
echo "配置$software程序!"
sudo cp $folder/* /usr/bin/
sudo mv /usr/bin/docker.service /etc/systemd/system/
echo "重新加载配置文件!"
systemctl daemon-reload
echo "启动$software服务!"
systemctl start $software
echo "添加开启自动启动!"
systemctl enable docker.service
echo "$software运行状态!"
systemctl status $software
echo "docker安装版本如下"
$software -v
echo "docker-compose安装版本如下"
docker-compose -v
sudo rm -rf $folder
卸载
# !/bin/bash
# 一键卸载Docker
# Create : 2019-12-13
# Update : 2019-12-13
# @Autor : wuduoqiang
# 要卸载的软件
software=docker
function undocker(){
echo "禁止启动"
systemctl enable docker.service
echo "停止服务"
systemctl stop $software
echo "移除文件"
cd /usr/bin/
sudo rm docker docker-containerd docker-containerd-ctr docker-containerd-shim dockerd docker-init docker-proxy docker-runc docker-compose
cd /etc/systemd/system/
sudo rm docker.service
echo "卸载成功"
exit
}
# 判断服务是否在运行
systemctl status $software &>/dev/null
if [ $? -eq 0 ];then
undocker
else
echo "docker未安装!"
exit
fi
# 判断命令是否存在
if $(command -v $software > /dev/null 2>&1);
then
undocker
else
echo "docker未安装!"
exit
fi
# 判断源码包是否安装过
if rpm -q $software &>/dev/null;
then
undocker
else
echo "docker未安装!"
exit
fi
欢迎来到这里!
我们正在构建一个小众社区,大家在这里相互信任,以平等 • 自由 • 奔放的价值观进行分享交流。最终,希望大家能够找到与自己志同道合的伙伴,共同成长。
注册 关于