I am trying to create a bash script utility to check if docker daemon is running on my server. Is there a better way to check if the docker daemon is working on my server besides running such 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
I would like to create a bash script shell that will check if my docker daemon is working. If it works, do nothing, but if it is not, the docker daemon will start.
My pseudo code is something like this. I am thinking about parsing the output of my ps -ef, but I just wanted to know if there is a more efficient way to make my pseudo-code.
if (docker is not running)
run docker
end
PS I'm not a Linux specialist, and I just need to make this utility in my own environment.
bash shell docker
Mark estrada
source share