For OS X users (Mojave 10.14.3)
Here is what i use in my Bash script to test if Docker is running or not
# Check if docker is running
if ! docker info >/dev/null 2>&1; then
echo "Docker does not seem to be running, run it first and retry"
exit 1
fi