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
:Thedocker run
command fails by itselfexit code
126
: The supplied command cannot be invokedexit code
127
: The supplied command cannot be foundOther, non-zero, application dependent exit code.
As you can recall, in the previous chapters we have been using the dockerps
command to list the...