Below is a ready-to-use script. Review and adapt variables to your environment.
#!/usr/bin/env bash
SERVICES=("docker" "sshd" "cron")
for s in "${SERVICES[@]}"; do
if ! systemctl is-active --quiet "$s"; then
echo "Restarting $s"; systemctl restart "$s"
fi
done