docker部署

说明

工作中总有人为我怎么装docker,决定写个脚本快速安装

Docker快速安装

1
2
3
4
5
6
7
8
9
10
11
12
13
14
eecho "检查Docker......"
docker -v
if [ $? -eq 0 ]; then
echo "检查到Docker已安装!"
else
echo "安装docker环境..."
yum -y install yum-utils
yum-config-manager --add-repo https://mirrors.aliyun.com/docker-ce/linux/centos/docker-ce.repo
yum makecache fast
yum -y install docker-ce
systemctl start docker
systemctl enable docker
echo "安装docker环境...安装完成!"
fi

Docker Compose快速安装

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
docker-compose -v
if [ $? -eq 0 ]; then
echo "检查到Docker Compose已安装!"
else
api_url="https://api.github.com/repos/docker/compose/releases/latest"
new_ver=$(curl -s ${api_url} --connect-timeout 10| grep 'tag_name' | cut -d\" -f4)
echo ${new_ver}
if [ ! -n "${new_ver}" ]; then
echo "网络连接超时,安装失败请重新执行本脚本,直至输出compose安装成功"
else
curl -L https://get.daocloud.io/docker/compose/releases/download/$new_ver/docker-compose-`uname -s`-`uname -m` > /usr/local/bin/docker-compose
chmod +x /usr/local/bin/docker-compose
echo "docker-compose 安装成功"
fi
fi

本博客所有文章除特别声明外,均采用 CC BY-SA 4.0 协议 ,转载请注明出处!