点击查看代码
#!/bin/sh
echo "开始安装docker/docker-compose"
echo "1) 安装/升级Docker客户端,安装必要的一些系统工具"
yum update -y
yum install -y yum-utils device-mapper-persistent-data lvm2
echo "2) 添加软件源信息"
yum-config-manager --add-repo http://mirrors.aliyun.com/docker-ce/linux/centos/docker-ce.repo
echo "3) 更新并安装"
yum makecache fast
yum -y install docker-ce
echo "4) 开启Docker服务"
service docker start
echo "5) 配置镜像加速器,为docker容器设置默认网段"
mkdir -p /etc/docker
tee /etc/docker/daemon.json <<-'EOF'
{
"bip": "10.0.0.1/24",
"default-address-pools": [
{
"base": "10.8.0.0/16",
"size": 24
}
],
"insecure-registries":["172.17.2.129:5000","http://172.17.2.129:5000"]
}
EOF
echo "6) 重启,并设置开机自启"
systemctl daemon-reload
systemctl restart docker
systemctl enable docker
echo "7) docker-compose安装"
curl -L "https://github.com/docker/compose/releases/latest/download/docker-compose-(uname -s)-(uname -m)" -o /usr/local/bin/docker-compose
echo "8) 加上可执行权限"
chmod +x /usr/local/bin/docker-compose