Container exit codes and restart policies

You can specify the so called restart policy using the--restart switch with the docker run command. Restart policy tells Docker how to behave on container shutdown. It can be restarted to minimize downtime, for example if running on production server. However, before we explain the Docker restart policy, let's focus on the 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 docker run as a parameter.

When the dockerrun command ends with a non-zero code, the exit codes follow the chroot standard, as you can see in the following example:

  • exit code 125:The docker run command fails by itself ...

Get Developing with Docker now with O’Reilly online learning.

O’Reilly members experience live online training, plus books, videos, and digital content from 200+ publishers.