2019-01-07 08:44:36 +00:00
|
|
|
#!/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}'
|
2019-01-07 08:44:36 +00:00
|
|
|
exit 1
|
|
|
|
fi
|
|
|
|
}
|
|
|
|
|
|
|
|
checkSudo
|
|
|
|
|
|
|
|
if [ $# -eq 1 ];then
|
|
|
|
|
|
|
|
case $1 in
|
|
|
|
"run")
|
2019-01-07 09:02:35 +00:00
|
|
|
docker-compose up;;
|
2019-01-07 08:44:36 +00:00
|
|
|
|
|
|
|
"restart")
|
2019-01-07 09:02:35 +00:00
|
|
|
docker-compose up --no-recreate;;
|
2019-01-07 08:44:36 +00:00
|
|
|
|
|
|
|
"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-07 08:44:36 +00:00
|
|
|
*)
|
2019-01-10 03:18:18 +00:00
|
|
|
echo -e 'usage ./docker.sh {run|restart|rm|logs}';;
|
2019-01-07 08:44:36 +00:00
|
|
|
esac
|
|
|
|
|
|
|
|
fi
|