#!/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 版本
yum install -y docker-ce # 默认安装最新版本 docker
# yum install docker-ce-<VERSION_STRING> (指定安装版本)
# yum install docker-ce-18.03.1.ce
else
echo "已经成功安装docker"
fi
}
dockerCangku(){
mkdir -p /etc/docker; rm -rf /etc/docker/daemon.json; touch /etc/docker/daemon.json ; ls /etc/docker
tee /etc/docker/daemon.json <<-'EOF'
{
"registry-mirrors": ["https://hub-mirror.c.163.com"]
}
EOF
systemctl daemon-reload ; systemctl restart docker ; systemctl enable docker ; docker -v
# 重载docker配置,重启docker,加入开机启动
docker pull centos:7
# 拉取centos7 镜像
docker images
docker ps -a
#docker rmi -f nginx
}
DockerInstall
dockerCangku
# wget eisc.cn/file/shell/docker-install.sh ; sh docker-install.sh
Powered by ddoss.cn 12.0
©2015 - 2024 ddoss
渝公网安备50011302222260号 渝ICP备2024035333号 【实验平台安全承诺书】 小绿叶技术社区,优化网络中,点击查看配置信息
您的IP:192.168.122.82,2024-10-10 19:35:34,Processed in 0.02462 second(s).