Using Bash to Check Your Docker App is Running

January 25, 2021

Checking if you application is up is always a worry. I recently had a problem where I realized I only had the TurboAPI status page ( to monitor the uptime of the app.

So what could I do? Unfortunately, I can’t use TurboAPI to monitor TurboAPI. But, like levelsio I love a quick and dirty script. So, I decided to write one that would do the following:

  1. Check Docker was running
  2. Check at least 1 instance of the app was running
  3. Notify me via slack if there are any issues

The script below assumes on you running Docker on a single server. To use it you need to simply generate some Slack webhook URL’s and replace the “” link with them.

Hope you enjoy!

result=$( docker ps -q -f name=turboapi_app )
echo "Checking container's exist"

systemctl show --property ActiveState docker | grep 'ActiveState=active' &> /dev/null
if [ $? != 0 ]; then
   message="🐳 Docker is Not Running!"
   echo $message
   curl -X POST --data-urlencode "payload={\"text\":\"${message}\"}"

if [[ -n "$result" ]]; then
  echo "Container exists"
  message="🔴 TurboAPI Container does not exist"
  curl -X POST --data-urlencode "payload={\"text\":\"${message}\"}"