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

前端 未结 17 1323
既然无缘
既然无缘 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:31

    Run:

    docker version
    

    If docker is running you will see:

    Client: Docker Engine - Community
     Version:           ...
     [omitted]
    
    Server: Docker Engine - Community
     Engine:
      Version:          ...
     [omitted]
    

    If docker is not running you will see:

    Client: Docker Engine - Community
     Version:           ...
     [omitted]
    
    Error response from daemon: Bad response from Docker engine
    

提交回复
热议问题