When I create containers I'm specifying a restart policy, but this is not shown in docker ps
, and it doesn't appear any format string shows this either.
Does anyone know how to see the restart policy of a running container(s)?
When I create containers I'm specifying a restart policy, but this is not shown in docker ps
, and it doesn't appear any format string shows this either.
Does anyone know how to see the restart policy of a running container(s)?
For single line of the code:
Yes, it is possible using
docker inspect
which isjson
format and just need to query it.Here is relevant output of docker inspect for a running container
zen_easley
. Note to change container name as suitable for your environment.docker inspect zen_easley
You can just run the following command to get the same and its output.
If you see
RestartPolicy
has two propertiesName, MaximumRetryCount
and no, 0 are the values respectively in the above outputYou may also get the individual property value, say
Name
by using below command, appending.Name
to the above command:You can get this via
docker inspect
.Just the policy name:
Or the entire policy (including e.g. max retry count):
I did this little script to check all the containers and their policy:
Hope it helps to somebody!