执行时显示解释头有问题,则是windows与linux之间的换行符问题
1 2 3 4
| 方法1:用vim打开执行命令: set fileformat=unix 方法2:用工具dos2unix dos2unix ./your_script.sh
|
以下为安装docker的脚本
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24
| #!/bin/bash echo "开始安装docker"
yum install -y yum-utils device-mapper-persistent-data lvm2
yum-config-manager --add-repo http://mirrors.aliyun.com/docker-ce/linux/centos/docker-ce.repo
yum -y install docker-ce docker-ce-cli containerd.io
echo "net.ipv4.ip_forward = 1" | sudo tee -a /etc/sysctl.conf
sysctl -p
modprobe ip_tables
cat /proc/sys/net/ipv4/ip_forward
iptables -nL
systemctl stop firewalld && systemctl disable firewalld
systemctl restart docker
systemctl start docker && systemctl enable docker
|