By using the --restart option with the docker run command you can specify a restart policy. This tells Docker how to react when a container shuts down. The container then can be restarted to minimize downtime, for example if running on a production server. However, before we explain the Docker restart policy, let's focus for a while on exit codes. The exit code is crucial information, it tells why the container failed to run or why it exited. Sometimes it's related to the contained command you will give to the docker run as a parameter. When the docker run command ends with a non-zero code, the exit codes follow the chroot standard, as you can see here:
- exit code 125: The docker run command fails by itself
- exit code126: The supplied command cannot be invoked
- exit code 127: The supplied command cannot be found
- Other, non-zero, application dependent exit...