Get the App
SLTechnology News&Howtos  ›  Servers  › 

How docker restarts the container

Shulou Source: shulou.com Published: 2022-06-01 02:43:24 10月04日 Update

This article introduces docker how to restart the container, the content is very detailed, interested friends can use for reference, I hope it can be helpful to you.

The restart strategy of the docker container is a startup strategy for the production environment, which can be ignored in the development process. The restart of the Docker container is done by the Docker daemon, so it is closely related to the daemon.

The restart strategy for the Docker container is as follows:

No, the default policy, does not restart the container when it exits

On-failure, the container will be restarted only when the container exits abnormally (the exit status is not 0)

On-failure:3, restart the container when it exits abnormally, up to 3 times

Always, always restart the container when it exits

Unless-stopped, which always restarts the container when it exits, but does not consider containers that have been stopped when the Docker daemon starts

View docker container restart policy

Docker inspect Container ID

Docker run-d-- restart=always bba-208docker run-d-- restart=on-failure:10 bba-208

-restart option for docker run

With the-restart option, you can set the container restart policy to determine whether the Docker daemon restarts the container that just exited when the container exits.

The-restart option is usually used only for containers in detached mode.

The-restart option cannot be used with the-rm option. Obviously, the-restart option applies to containers in detached mode, while the-rm option applies to containers in foreground mode.

When docker ps looks at containers, the only possible states for containers that use the-restart option are Up or Restarting.

So much for sharing about how docker restarts the container. I hope the above content can be helpful to you and learn more. If you think the article is good, you can share it for more people to see.

Tags: Containers policies processes patterns status content more help yes closely related interest only at the same time guys partners articles are made up of environment knowledge articles Apple Docker Huawei Linux macOS MariaDB Microsoft MySQL NVidia OPPO Reno MySQL Apple Xiaomi Shulou Information NVidia