Empresas
Empleos
  • Sobre nosotros
  • Soluciones
    • Publicación de vacantes
      Publica tu vacante y recibe candidatos calificados en 48h.
    • Evaluación de candidatos
      500+ pruebas técnicas y psicológicas, más anti-fraude.
    • Headhunting
      Búsqueda ejecutiva a la medida de principio a fin.
    • Nómina + EOR
      Dispersión de nómina y EOR en más de 15 países de LATAM.
  • Precios
  • Empleos

0

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

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)?

over 4 years ago · Santiago Trujillo
3 Respuestas
Responde la pregunta

0

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
over 4 years ago · Santiago Trujillo Denunciar

0

You can get this via docker inspect.

Just the policy name:

docker inspect --format '{{.HostConfig.RestartPolicy.Name}}' <container-id>

Or the entire policy (including e.g. max retry count):

docker inspect --format '{{json .HostConfig.RestartPolicy}}' <container-id>
over 4 years ago · Santiago Trujillo Denunciar

0

I did this little script to check all the containers and their policy:

#!/usr/bin/env bash
#Script to check the restart policy of the containers

readarray -t CONTAINERS < <(docker ps -a | grep -v NAMES | awk '{print $NF}')

for item in "${CONTAINERS[@]}"; do

    #Hard-Bash way
    #data=$(docker inspect "${item}" | grep -A 1 RestartPolicy | awk -F '"' '{print $4}' | tail -n 1)

    #Docker-pr0 way
    data=$(docker inspect -f "{{ .HostConfig.RestartPolicy.Name }}" "${item}")

    echo "Container: ${item} / RestartPolicy: ${data}"
done

Hope it helps to somebody!

over 4 years ago · Santiago Trujillo Denunciar
Responde la pregunta
Encuentra empleos remotos

¡Descubre la nueva forma de encontrar empleo!

Top de empleos
Top categorías de empleo
Empresas
Publicar vacante Precios Comercial
Legal
Términos y condiciones Política de privacidad
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomiéndame algunas ofertas
Necesito ayuda