Centos 7.4 自动初始化docker环境,配置docker镜像仓库
#/bin/bash #Auto configuration docker env #Author yarn #2018-9-10 11:53:45 ###################### REGISTRY=www.registry.example.cn HOST_NAME=application cat /etc/redhat-release read -p "If your operating system version is Centos Linux 7.4 (Croe),Please press yes,If not press no:" anw case $anw in [Yy][Ee][Ss]|[Yy]) systemctl status firewalld systemctl stop firewalld systemctl disable firewalld setenforce 0 hostnamectl set-hostname $HOST_NAME sed -i "s/SELINUX=enforcing/SELINUX=disabled/g" /etc/sysconfig/selinux yum -y install vim zip unzip rsync yum-utils device-mapper-persistent-data lvm2 yum-config-manager --add-repo http://mirrors.aliyun.com/docker-ce/linux/centos/docker-ce.repo yum makecache fast yum -y install docker-ce systemctl start docker touch /etc/docker/daemon.json echo '{"registry-mirrors": ["https://registry.docker-cn.com"]}' >> /etc/docker/daemon.json echo '{"insecure-registries": ["http://$REGISTRY:5000"]} ' >> /etc/docker/daemon.json sed -i s#ExecStart=/usr/bin/dockerd#"ExecStart=/usr/bin/dockerd --insecure-registry=$REGISTRY:5000"#g /usr/lib/systemd/system/docker.service systemctl daemon-reload
systemctl restart docker
docker ps
;; [Nn][Oo]|[Nn]) exit 1 ;; esac