docker-¿cómo se deshabilita el reinicio automático en un contenedor?


Puedo habilitar el reinicio automático con --restart=always, pero después de detener el contenedor, ¿cómo desactivo ese atributo?

Normalmente corro un servidor web y normalmente mapeo el puerto 80:

docker run -d --restart=always -p 80:80 -i -t myuser/myproj /bin/bash

Pero hay momentos en los que quiero ejecutar una versión más nueva de mi imagen, pero quiero mantener el contenedor antiguo. El problema es que si hay múltiples contenedores con --restart=always, solo uno de ellos (random?) se inicia porque todos están contendiendo por el puerto 80 en el host.

 59
Author: Brad Grissom, 2016-06-02

2 answers

Puede usar la opción --restart=unless-stopped, como @Shibashis mencionó, o actualizar la política de reinicio (esto requiere docker 1.11 o posterior);

Ver la documentación de para docker update y Políticas de reinicio de Docker.

docker update --restart=no my-container

Que actualiza la directiva de reinicio para un contenedor existente(my-container)

 120
Author: thaJeztah,
Warning: date(): Invalid date.timezone value 'Europe/Kyiv', we selected the timezone 'UTC' for now. in /var/www/agent_stack/data/www/ajaxhispano.com/template/agent.layouts/content.php on line 61
2018-06-01 12:39:48

Puede iniciar su contenedor con --restart=unless-stopped.

 17
Author: Shibashis,
Warning: date(): Invalid date.timezone value 'Europe/Kyiv', we selected the timezone 'UTC' for now. in /var/www/agent_stack/data/www/ajaxhispano.com/template/agent.layouts/content.php on line 61
2016-06-02 18:11:47