0 votes
in Docker by
Can a container restart by itself?

2 Answers

0 votes
by

No, it’s not possible for a container to restart by itself. By default the flag -restart is set to false.

0 votes
by
Yes, it is possible only while using certain docker-defined policies while using the docker run command. Following are the available policies:

1. Off: In this, the container won’t be restarted in case it's stopped or it fails.

2. On-failure: Here, the container restarts by itself only when it experiences failures not associated with the user.

3. Unless-stopped: Using this policy, ensures that a container can restart only when the command is executed to stop it by the user.

4. Always: Irrespective of the failure or stopping, the container always gets restarted in this type of policy.
...