How to check if docker daemon is running? : <p>I am trying to create a bash utility script to check if a docker daemon is running in my server.
Is there a better way of checking if the docker daemon is running in my server other than running a code like this?</p>

<pre><code>ps -ef | grep docker
root      1250     1  0 13:28 ?        00:00:04 /usr/bin/dockerd --selinux-enabled
root      1598  1250  0 13:28 ?        00:00:00 docker-containerd -l unix:///var/run/docker/libcontainerd/docker-containerd.sock --shim docker-containerd-shim --metrics-interval=0 --start-timeout 2m --state-dir /var/run/docker/libcontainerd/containerd --runtime docker-runc
root     10997 10916  0 19:47 pts/0    00:00:00 grep --color=auto docker
</code></pre>

<p>I would like to create a bash shell script that will check if my docker daemon is running.  If it is running then do nothing but if it is not then have the docker daemon started.</p>

<p>My pseudocode is something like this.  I am thinking of parsing the output of my ps -ef but I just would like to know if there is a more efficient way of doing my pseudocode.</p>

<blockquote>
  <p>if(docker is not running)</p>

<pre><code>          run docker
</code></pre>
  
  <p>end</p>
</blockquote>

<p>P.S.
I am no linux expert and I just need to do this utility on my own environment.</p>
