linux中建立sh文件并贴如下内容“
(1)vi ./test.sh #创建新的sh文件
(2)chmod 775 test.sh #给test.sh可执行权限
(3)./test.sh #执行创建好的sh文件
sh文件内容:
#!/bin/bash
yum -y install wget
ln -sf /usr/share/zoneinfo/Asia/Shanghai /etc/localtime;
systemctl stop firewalld.service;
systemctl disable firewalld.service;
firewall-cmd --state;
mkdir -p /data/
cd /data/;
wget http://oh7g4ad14.bkt.clouddn.com/docker-engine-selinux-1.12.6-1.el7.centos.noarch.rpm;
wget http://oh7g4ad14.bkt.clouddn.com/docker-engine-1.12.6-1.el7.centos.x86_64.rpm;
mkdir -p docker;
ln -s /data/docker /var/lib/docker;
yum -y install policycoreutils-python selinux-policy-base selinux-policy-targeted libseccomp libtool-ltdl device-mapper-libs;
rpm -ivh docker-engine-selinux-1.12.6-1.el7.centos.noarch.rpm
rpm -ivh docker-engine-1.12.6-1.el7.centos.x86_64.rpm
service docker start
tee /etc/docker/daemon.json <<-'EOF'
{"registry-mirrors": ["https://registry.docker-cn.com"]}
EOF
service docker restart
至此docker安装完成;设置docker开机自启动:systemctl enable docker
docker容器设置开机自启动:docker update --restart=always xxx