各位大神,在root用户下执行的shell脚本如何在进入docker之后执行,望指教,附上一段代码作为示例,这个代码执行不了。各位看看
#!/bin/bash
PATH=/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:/usr/games:/usr/local/games
HOST_IP=ifconfig eth0 | awk '/inet addr:/{ print $2 }' | awk -F: '{print $2 }'
cd docker-1.9.1
dpkg -i *.deb
sed -i '7s/^#//' /etc/default/docker
grep -q 'DOCKER_OPTS="--dns 8.8.8.8 --dns 8.8.4.4' /etc/default/docker
if [ $? -eq 0 ]
then
sed -i '7c DOCKER_OPTS="--dns 8.8.8.8 --dns 8.8.4.4 -g /iflytek/docker"' /etc/default/docker
else
echo no modify!!!
fi
service docker restart
cd /root
cat nginx-2.0.tar.gz | docker import - nginx:v2.0
docker images
docker run -it --name=nginx --net=host --restart=always --privileged=true nginx:v2.0 /bin/bash -c "
cd /iflytek/docker/aufs/mnt
nginx=ls -t | head -n 1
cd $nginx/usr/local/webservices/nginx/conf/
grep -q 'listen 80 backlog=65535;' $nginx/usr/local/webservices/nginx/conf//conf/nginx.conf
if [ $? -eq 0 ]
then
echo not need modify!!!
else
sed -i '27c listen 80 backlog=65535;' $nginx/usr/local/webservices/nginx/conf//conf/nginx.conf
fi
"