How to check if the docker engine and a docker container are running?

前端 未结 17 1319
既然无缘
既然无缘 2021-01-30 05:03

In a script, I need to check:

a) Is the docker engine running?
b) Given a container name, is that docker container running?

[the initial wording of this

17条回答
  •  深忆病人
    2021-01-30 05:28

    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
    

提交回复
热议问题