docker run --restart=always -d <container>
By default, Docker will not restart containers when the Docker daemon restarts, for example after a host system reboot. Docker provides a restart policy for your containers by supplying the
--restart command line option. Supplying
--restart=always will always cause a container to be restarted after the Docker daemon is restarted. However when that container is manually stopped (e.g. with
docker stop <container>), the restart policy will not be applied to the container.
Multiple options can be specified for
--restart option, based on the requirement (
--restart=[policy]). These options effect how the container starts at boot as well.
|no||The default value. Will not restart container automatically, when container is stopped.|
|on-failure[:max-retries]||Restart only if the container exits with a failure (|
|always||Always restart the container regardless of the exit status. When you specify |
|unless-stopped||Always restart the container regardless of its exit status, but do not start it on daemon startup if the container has been put to a stopped state before.|