工具与资源中心
帮助开发者更加高效的工作,提供围绕开发者全生命周期的工具与资源
https://developer.aliyun.com/tool?spm=a1z389.11499242.0.0.654524138C8eDN&utm_content=g_1000283979
简介: 一键安装,并创建test镜像
#!/bin/bash
repo="centos-yum.sh"
if [ ! -e $repo ]; then # -e 判断文件存在;参考:Shell if 条件判断文件或目录
yum install -y wget
wget www.eisc.cn/file/shell/centos-yum.sh ; sh centos-yum.sh
else
echo "yum已经切换"
fi
DockerInstall(){
dci=`rpm -qa | grep docker | wc -l`
if [ $dci -lt 1 ]
then
echo "正在安装docker =======》"
yum -y remove docker docker-common docker-selinux docker-engine
# 卸载旧版本docker
yum install -y yum-utils device-mapper-persistent-data lvm2
# 配置yum 源码
yum-config-manager --add-repo https://download.docker.com/linux/centos/docker-ce.repo
# 添加docker yum 源码
yum list docker-ce --showduplicates | sort -r
# 查看docker 版本
cat /dev/null > /etc/docker/daemon.json ;
# 先清空文件内容重新写入
cat > /etc/docker/daemon.json << EOF
{
"insecure-registries": ["registry.local", "127.0.0.1:5001", "10.10.13.42:5000"],
"registry-mirrors": ["https://registry.docker-cn.com"],
"bip": "172.18.18.1/24",
"data-root": "/var/lib/docker",
"storage-driver": "overlay2",
"live-restore": true,
"log-opts": {
"max-size": "500m"
}
}
EOF
# 文件中不需要IPv6
# 配置镜像加速器
yum install -y docker-ce # 默认安装最新版本 docker
# yum install docker-ce-<VERSION_STRING> (指定安装版本)
# yum install docker-ce-18.03.1.ce
systemctl start docker # 启动docker
systemctl enable docker # 开机启动
docker version # 查看docker版本号
docker run hello-world # 启动一个docker 验证是否安装成功
else
echo "已经成功安装docker"
fi
}
DockerInstall
dockerCangku(){
systemctl daemon-reload
systemctl restart docker.service
systemctl status docker -l
docker info
docker pull centos:7
# 拉取centos7 镜像
}
dockerCangku
# wget eisc.cn/file/shell/docker-install.sh ; sh docker-install.sh