一鍵部署Docker CE(CentOS 7)
阿新 • • 發佈:2019-01-09
一鍵部署指令碼
#!/bin/sh # @author ling # 定義顯示顏色 RED='\e[1;91m' GREEN='\e[1;92m' WITE='\e[1;97m' NC='\e[0m' # centos7環境中安裝docker function install_docker_in_contos7() { echo "Install docker in centos7!" echo "Remove old docker!" yum remove docker docker-common docker-selinux docker-engine && echo -e $GREEN"Remove old docker success!"$NC echo "Install docker dependent packages!" yum install -y yum-utils device-mapper-persistent-data lvm2 && echo -e $GREEN"Install docker dependent packages success!"$NC echo "Add yum repo!" yum-config-manager --add-repo https://mirrors.ustc.edu.cn/docker-ce/linux/centos/docker-ce.repo && echo -e $GREEN"Add yum repo success!"$NC echo "Install docker-ce!" yum makecache fast && yum install -y docker-ce && echo -e $GREEN"Install docker-ce success!"$NC echo "Chkconfig docker on!" systemctl enable docker && systemctl start docker && echo -e $GREEN"Chkconfig docker on success!"$NC echo "{\"registry-mirrors\": [\"http://hub-mirror.c.163.com\"]}" >> /etc/docker/daemon.json systemctl daemon-reload && systemctl restart docker && echo -e $GREEN"Install docker in centos7 success!"$NC echo "Stop firewalld!" systemctl stop firewalld && systemctl disable firewalld && echo -e $GREEN"Stop firewalld success!"$NC echo "Install iptables services!" yum -y install iptables-services && systemctl enable iptables && systemctl start iptables && echo -e $GREEN"Install iptables services success!"$NC echo "Reload docker!" systemctl restart docker && echo -e $GREEN"Reload docker success!"$NC } install_docker_in_contos7