12306/docker.sh

38 lines
593 B
Bash
Raw Normal View History

#!/bin/bash
#author: tan
#date: 2019-01-07
# a script to control docker's container create restart reload and rm function
function checkSudo (){
if [ $UID -ne 0 ];then
echo -e 'it must be root!'
2019-01-10 03:18:18 +00:00
echo -e 'usage ./docker.sh {run|restart|rm|logs}'
exit 1
fi
}
checkSudo
if [ $# -eq 1 ];then
case $1 in
"run")
2019-01-07 09:02:35 +00:00
docker-compose up;;
"restart")
2019-01-07 09:02:35 +00:00
docker-compose up --no-recreate;;
"rm")
2019-01-07 09:02:35 +00:00
docker-compose rm -f;;
"drun")
docker-compose up -d;;
2019-01-10 03:18:18 +00:00
"logs")
docker-compose logs;;
2019-01-07 09:02:35 +00:00
*)
2019-01-10 03:18:18 +00:00
echo -e 'usage ./docker.sh {run|restart|rm|logs}';;
esac
fi