安装docker
#!/bin/bash
# coding: utf-8
# Copyright (c) 2018
set -e #返回值为0时,退出脚本
echo "1. 备份yum"
{
for i in /etc/yum.repos.d/*.repo;do cp $i ${i%.repo}.bak;done
rm -rf /etc/yum.repos.d/*.repo
} || {
echo "备份出错,请手动执行"
exit 1
}
echo "2. 获取网络yum"
{
wget -P /etc/yum.repos.d/ http://mirrors.aliyun.com/repo/Centos-7.repo >/dev/null 2>&1
wget -P /etc/yum.repos.d/ http://mirrors.163.com/.help/CentOS7- -163.repo >/dev/null 2>&1
yum clean >/dev/null 2>&1
yum repolist >/dev/null 2>&1
} || {
echo "获取出错,请手动执行"
exit 1
}
echo "3. 安装docker-ce......"
{
yum -y install yum-utils >/dev/null 2>&1
yum-config-manager --add-repo http://mirrors.aliyun.com/docker-ce/linux/centos/docker-ce.repo >/dev/null 2>&1
yum clean >/dev/null 2>&1
yum repolist >/dev/null 2>&1
yum -y install epel-release docker-ce >/dev/null 2>&1
} || {
echo "安装出错,请手动安装"
exit 1
}
systemctl start docker >/dev/null 2>&1
systemctl enable docker >/dev/null 2>&1
echo "4. 添加内和参数"
{
cat <<EOF>> /etc/sysctl.conf
net.bridge.bridge-nf-call-ip6tables = 1
net.bridge.bridge-nf-call-iptables = 1
EOF
sysctl -p >/dev/null 2>&1
}
echo "5. 添加镜像加速"
{
cat <<EOF>> /etc/docker/daemon.json
{
"registry-mirrors": [
"https://registry.docker-cn.com"
]
}
EOF
}
systemctl daemon-reload >/dev/null 2>&1
systemctl restart docker >/dev/null 2>&1
rm -rf ./*.sh
继续阅读与本文标签相同的文章
-
还在关注“宏颜获水”?DuerOS 5.0让你更惊讶
2026-05-19栏目: 教程
-
「云栖大会现场」揭秘“淘富成真”,阿里+富士康如何孵化硬件
2026-05-19栏目: 教程
-
重磅!Apollo 5.0来了,百度变身「老司机」!
2026-05-19栏目: 教程
-
谷歌AI模型ML-Jam激发音乐家创作,人机合作或成未来大势!
2026-05-19栏目: 教程
-
OCP-052考试题库汇总(49)-CUUG内部解答版
2026-05-19栏目: 教程
