How to check if docker daemon is running?

后端 未结 7 780
庸人自扰
庸人自扰 2020-12-15 04:31

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 serv

7条回答
  •  眼角桃花
    2020-12-15 04:42

    You have a utility called pgrep on almost all the Linux systems.

    You can just do:

    pgrep -f docker > /dev/null || echo "starting docker"
    

    Replace the echo command with your docker starting command.

提交回复
热议问题