frontContainer=4ab8
if [ "$( docker container inspect -f '{{.State.Status}}' $frontContainer )" == "running" ]; then
echo running
else
echo notRunnig
sudo docker start $frontContainer
fi
sccript.sh
$ crontab -e
: 일반유저권한
$ sudo crontab -e
: sudo유저권한
* * * * * bash /home/restart_script.sh > /home/restart_script.sh.log 2>&1
크론탭 최소 단위인 1분마다 체크
참고
https://stackoverflow.com/questions/43721513/how-to-check-if-the-docker-engine-and-a-docker-container-are-running
https://stackoverflow.com/questions/3411048/unexpected-operator-in-shell-programming
https://jdm.kr/blog/2