In fact, most likely the main application of your container crashed, not your container.
When the process with identifier No. 0 stops or a failure occurs in the container, the container automatically stops.
For your concern, the restart option (from the docker launch command) is one of the possibilities, as Andy claims.
Another possibility is to use a supervisor as the main container process. Your application will be launched and supervised by the supervisor. Supervisord will provide you with many options to deal with the collapse of your application. You have many useful options for registration, signal processing ...
See https://docs.docker.com/articles/using_supervisord/ and http://supervisord.org/ for more details.
source share