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

前端 未结 17 1294
既然无缘
既然无缘 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条回答
  •  闹比i
    闹比i (楼主)
    2021-01-30 05:34

    If the underlying goal is "How can I start a container when Docker starts?"

    We can use Docker's restart policy

    To add a restart policy to an existing container:

    Docker: Add a restart policy to a container that was already created

    Example:

    docker update --restart=always 
    

提交回复
热议问题