Is it possible to show the restart policy of a running Docker container?

Yes, it is possible using docker inspect which is json 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
"HostConfig": {
            "Binds": null,
            "ContainerIDFile": "",
            "LogConfig": {
                "Type": "json-file",
                "Config": {}
            },
            "NetworkMode": "default",
            "PortBindings": {},
            "RestartPolicy": {
                "Name": "no",
                "MaximumRetryCount": 0
            },
            "AutoRemove": true,

You can just run the following command to get the same and its output.

$ docker inspect -f "{{ .HostConfig.RestartPolicy }}"  zen_easley
{no 0}

If you see RestartPolicy has two properties Name, MaximumRetryCount and no, 0 are the values respectively in the above output

You may also get the individual property value, say Name by using below command, appending .Name to the above command:

docker inspect -f "{{ .HostConfig.RestartPolicy.Name }}"  zen_easley
no

Leave a Comment

Hata!: SQLSTATE[HY000] [1045] Access denied for user 'divattrend_liink'@'localhost' (using password: YES)