Difference between revisions of "Docker Start configuration behavior and restart policy"

From wikieduonline
Jump to navigation Jump to search
(Created page with "To configure the '''start configuration behavior or the restart policy''' for a container (both of them), use the <code>--restart</code> flag when using the <code>docker run</...")
 
Tag: New redirect
 
(3 intermediate revisions by the same user not shown)
Line 1: Line 1:
To configure the '''start configuration behavior or the restart policy''' for a container (both of them), use the <code>--restart</code> flag when using the <code>docker run</code> command. The value of the <code>--restart</code> flag can be any of the following:
+
#redirect [[Start configuration behavior and restart policy]]
 
 
*Do not automatically restart the container. (the default): <code>no</code>
 
*Restart the container if it exits due to an error, which manifests as a non-zero exit code: <code>on-failure</code>
 
*Restart the container unless it is explicitly stopped or Docker itself is stopped or restarted: <code>unless-stopped</code>
 
*Always restart the container if it stops: <code>always</code>
 
 
 
 
 
The following example starts a Redis container and configures it to always restart unless it is explicitly stopped or Docker is restarted:
 
 
 
<code>$ docker run -dit --restart '''unless-stopped''' redis</code>
 
With <code>[[/docker inspect/]] CONTAINER</code><ref>https://stackoverflow.com/questions/43108227/is-it-possible-to-show-the-restart-policy-of-a-running-docker-container</ref> you can verify <code>RestartPolicy</code> configuration.
 
 
 
To update restart policy execute:
 
:<code>[[/docker update/]]</code><ref>https://docs.docker.com/engine/reference/commandline/update/</ref> --restart=always CONTAINER_ID|CONTAINER_NAME<ref>docker update --restart=always 90bf248337dc</ref>
 
:If the container is started  with “--rm” flag, you cannot update the restart policy for it. The AutoRemove and RestartPolicy are mutually exclusive for the container.
 
 
 
 
 
== See also ==
 
* [[devOps/Docker/docker inspect|docker inspect]]
 
 
 
{{CC license}}
 
Source: https://en.wikiversity.org/wiki/DevOps/Docker/Start_configuration_behavior_and_restart_policy
 

Latest revision as of 11:02, 13 February 2020

Advertising: