《Docker一键自动安装/卸载脚本》

   今天分享一个docker脚本。
下载地址:https://github.com/alichina/kungfu/tree/master/docker-ce_autoinstall_and_uninstal;

国内下载地址:http://gitlab.alisunchina.com/Alisun/docker-ce_autoinstall_and_uninstal
这个脚本可以实现Docker的自动安装和卸载,是笔者练手时所写,需要的朋友可以下载试用一下。
   更多实用脚本持续更新中

#!/bin/bash
#######################################################
# Name: onekey_install_docker.sh                                 
# Version: v0.0.1                                 
# Function: Automatic deployment and installation of docker-ce based on CentOS 7.x system
# Author: alichina <Mail:sun946020@126.com | 微信公众号:sunleestudio>
# Create Date: 2019-12-06
#######################################################

function INSTALL {
# Step 1:卸载系统中旧的Docker
rpm -qa | grep docker | xargs yum remove -y

# Step 2:安装所需的依赖软件包
yum install -y yum-utils device-mapper-persistent-data lvm2

# Step 3: 配置Docker安装源
#yum-config-manager -add-repo https://download.docker.com/linux/centos/docker-ce.repo
yum-config-manager --add-repo http://mirrors.aliyun.com/docker-ce/linux/centos/docker-ce.repo \
	&& yum makecache fast

# Step 4:安装Docker
yum install -y docker-ce docker-ce-cli containerd.io

# Step 5:启动docker服务,并为设置开机自启动
systemctl start docker && systemctl enable docker \
	&& docker version
}

function UNINSTALL {
# Step 1:停止Docker服务
systemctl stop docker

# Step 2:卸载Docker软件
rpm -qa | grep docker | xargs yum remove -y

# Step 3:删除Docker运行生成的相关数据
rm -rf /var/lib/docker
}

echo '
		Please enter the action you want to perform:"install" | "uninstall"
		请输入您要执行的操作:“安装install” 或者 “卸载uninstall”'

read -p "Please enter the action you want to perform: " action

case $action in
	install)
		INSTALL
	;;
	uninstall)
		UNINSTALL && echo 'Docker uninstall Successfully'
	;;
	*)
		echo '
			The action you entered is not supported. 
			Please enter the following format: install | uninstall'
		exit 1
esac
  • 1
    点赞
  • 7
    收藏
    觉得还不错? 一键收藏
  • 2
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论 2
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值