~/Docker Auto Restart Containers
Jan 19, 2022
To have Docker containers restart automatically, use the --restart
option when running a container. This ensures containers come back up after a crash or system reboot.
Example:
|
|
Restart policies:
no
: Do not automatically restarton-failure
: Restart on non zero exit codeunless-stopped
: Always restart, unless stopped by useralways
: Always restart
You can also update restart policies on existing containers using:
|
|
For details, see the Docker restart policy docs.