Question - Is it possible for a container to restart by itself?
Answer -
Yes, it is possible. Docker defines certain policies to restart the container. These are Off: container won't be restarted if it stops or fails,
- On-failure: container restarts only when a failure that occurred is not due to the user,
- Unless-stopped: container restarts only when a user executes the command to stop it,
- Always: the container is always restarted irrespective of error or other issues.
- The command is:
$ docker run -dit — restart [unless-stopped|off|on-failure|always] [CONTAINER]