关于linux:linux-centos-安装docker-shell脚本

6次阅读

共计 1426 个字符,预计需要花费 4 分钟才能阅读完成。

工具与资源核心
帮忙开发者更加高效的工作,提供围绕开发者全生命周期的工具与资源
https://developer.aliyun.com/…


简介:一键装置,并创立 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/l…

                                            # 增加 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

正文完
 0