How to check if Docker is installed in a Unix shell script?

This question already has an answer here:

  • Check if a program exists from a Bash script 29 answers

  • 使用rickdenhaan评论中的答案的建议:

    if [ -x "$(command -v docker)" ]; then
        echo "Update docker"
        # command
    else
        echo "Install docker"
        # command
    fi
    

    这一个为我工作:

    if [[ $(which docker) && $(docker --version) ]]; then
        echo "Update docker"
        # command
      else
        echo "Install docker"
        # command
    fi
    
    链接地址: http://www.djcxy.com/p/57052.html

    上一篇: 检查是否安装了软件包,如果不是,则安装它

    下一篇: 如何检查Docker是否安装在Unix shell脚本中?