Restart Mode

In this lesson, you will be introduced to the restart mode which ensures that containers are always running until explicitly told not to.

When creating a container, you have the choice to set a restart mode. It tells Docker what to do when a container stops. A restart mode is set with the --restart switch.

When running server containers like we did earlier, we want them to always be up. It is very tempting to use the always restart mode. For instance:

It works great. Should the container start, or the Docker host itself restart, the container will restart so that it has a high uptime. But it actually works too well; if you try to stop the container using the docker stop command, it will not stop.

That’s probably not what you want. If you want your container to always be running except when you explicitly stop it, use the unless_stopped restart mode:

That way, your container will almost always be up, except when you don’t want it to.


Let’s take a look at monitoring in the next lesson.

.NET Core
Monitoring
Mark as Completed
Report an Issue