使用阿里云源快速安装docker

使用阿里云源快速安装docker,编辑脚本auto-docker.sh

if [[ "$(whoami)" != "root" ]]; then
    echo "please run this script as root !" >&2
    exit 1
fi
echo -e "\\033[31m the script only Support CentOS_7 x86_64 \\033[0m"
echo -e "\\033[31m system initialization script, Please Seriously. press ctrl+C to cancel \\033[0m"

HostName=$1
# 检查是否为64位系统,这个脚本只支持64位脚本
platform=$(uname -i)
if [[ $platform != "x86_64" ]];then
    echo "this script is only for 64bit Operating System !"
    exit 1
fi

if [[ "$1" == "" ]];then
    echo "The host name is empty."
    exit 1
else
	hostnamectl  --static set-hostname "$HostName"
	hostnamectl  set-hostname "$HostName"
fi

mkdir -p  /opt/backup/repo/
mv /etc/yum.repos.d/*.repo  /opt/backup/repo/
curl -o /etc/yum.repos.d/CentOS-Base.repo http://mirrors.aliyun.com/repo/Centos-7.repo
yum install -y yum-utils device-mapper-persistent-data lvm2 nfs-utils  conntrack-tools
yum-config-manager --add-repo http://mirrors.aliyun.com/docker-ce/linux/centos/docker-ce.repo

rpm --import https://mirrors.aliyun.com/kubernetes/yum/doc/rpm-package-key.gpg
rpm --import https://mirrors.aliyun.com/kubernetes/yum/doc/yum-key.gpg
yum makecache fast
yum install -y nmap unzip wget vim lsof xz net-tools yum-utils iptables-services ntpdate ntp-doc psmisc deltarpm yum-plugin-ovl etcd bash-completion

yum install -y yum-utils device-mapper-persistent-data lvm2 socat
yum install -y docker-ce-18.09.8 docker-ce-cli-18.09.8

systemctl enable docker
systemctl stop docker

mkdir -p /etc/docker
if [[ -f /etc/docker/daemon.json  ]] ; then
	cp /etc/docker/daemon.json /etc/docker/daemon.json.bak1
fi
echo -e '
{
 "storage-driver": "overlay2",
 "storage-opts": [ "overlay2.override_kernel_check=true" ],
 "registry-mirrors": ["https://4ux5p520.mirror.aliyuncs.com"],
 "exec-opts": ["native.cgroupdriver=systemd"],
 "data-root": "/data/docker", 
 "log-driver": "json-file",
 "log-opts": {
 "max-size": "100m"
 }
}

' > /etc/docker/daemon.json
systemctl daemon-reload
systemctl restart docker


echo "ok"

使用方法

bash auto-docker.sh   修改后主机名

给TA买糖
共{{data.count}}人
人已赞赏
未分类

阿里云产品通用优惠券

2018-10-10 18:03:02

安装脚本

使用阿里云源快速安装kubelet

2021-5-18 13:40:34

0 条回复 A文章作者 M管理员
    暂无讨论,说说你的看法吧
个人中心
今日签到
有新私信 私信列表
搜索