You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
34 lines
972 B
34 lines
972 B
2 years ago
|
#!/usr/bin/bash
|
||
|
|
||
|
set -e
|
||
|
unset c
|
||
|
color(){
|
||
|
declare -A c=([Error]=31 [Success]=32 [Warning]=33 [Info]=34)
|
||
|
#echo -e "\033[${c[$1]}m[`date +%T`]($1) $2\033[0m"
|
||
|
printf "\033[${c[$1]}m%-10s%-10s %-30s\033[0m\n" "[`date +%T`]" "($1)" "$2"
|
||
|
sleep 0.5
|
||
|
}
|
||
|
|
||
|
install(){
|
||
|
color Info "开始安装docker服务"
|
||
|
yum install -y yum-utils device-mapper-persistent-data lvm2 git && \
|
||
|
yum-config-manager --add-repo http://mirrors.aliyun.com/docker-ce/linux/centos/docker-ce.repo && \
|
||
|
yum install -y docker-ce
|
||
|
mkdir -p /etc/docker
|
||
|
color Success "安装完成"
|
||
|
color Info "开始配置镜像加速器"
|
||
|
tee /etc/docker/daemon.json <<-'EOF'
|
||
|
{
|
||
|
"registry-mirrors": ["https://pilvpemn.mirror.aliyuncs.com"]
|
||
|
}
|
||
|
EOF
|
||
|
cat >> /etc/sysctl.conf <<EOF
|
||
|
net.bridge.bridge-nf-call-ip6tables = 1
|
||
|
net.bridge.bridge-nf-call-iptables = 1
|
||
|
net.ipv4.ip_forward=1
|
||
|
EOF
|
||
|
systemctl daemon-reload && \
|
||
|
systemctl enable docker --now
|
||
|
}
|
||
|
install
|
||
|
color Success "配置完成"
|