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.
These policies can be used as: docker run -dit — restart [restart-policy-value] [container_name]