docker自动部署脚本
#!/bin/bash
#yangchen
#uninstall for docker
sudo yum remove docker \
docker-client \
docker-client-latest \
docker-common \
docker-latest \
docker-latest-logrotate \
docker-logrotate \
docker-selinux \
docker-engine-selinux \
docker-engine
#dependent to install
sudo yum install -y yum-utils device-mapper-persistent-data lvm2
#download repo file
sudo yum-config-manager --add-repo
#install docker
sudo yum install -y docker-ce-18.06.1.ce-3.el7.x86_64
#configretion start for system
sudo systemctl enable docker
#enable ipv4 forward
echo 'net.ipv4.ip_forward=1' >> /etc/sysctl.config && \
systemctl restart network
#config mirrors
if [ ! -d /etc/docker ];then
mkdir /etc/docker
fi
touch /etc/docker/daemon.json && \
sudo tee /etc/docker/daemon.json <<-'EOF'
{
"registry-mirrors": ["https://kzflpq4b.mirror.aliyuncs.com"],
"insecure-registries": ["http://192.168.2.196"]
}
EOF
#startup to docker
sudo systemctl daemon-reload && \
sudo systemctl restart docker