{"id":176,"date":"2024-07-21T11:53:58","date_gmt":"2024-07-21T11:53:58","guid":{"rendered":"https:\/\/dockerpros.com\/?p=176"},"modified":"2024-07-21T11:53:58","modified_gmt":"2024-07-21T11:53:58","slug":"comment-configurer-les-strategies-de-redemarrage-dans-docker-vous-pouvez-definir-une-strategie-de-redemarrage-lors-de-lexecution-dun-conteneur-avec-loption-restart-bashdocker-run-re","status":"publish","type":"post","link":"https:\/\/dockerpros.com\/fr\/installation-and-configuration\/how-do-i-configure-restart-policies-in-docker\/","title":{"rendered":"How do I configure restart policies in Docker?"},"content":{"rendered":"<h1>Comment configurer les strat\u00e9gies de red\u00e9marrage dans Docker\n\nLes conteneurs Docker sont con\u00e7us pour \u00eatre \u00e9ph\u00e9m\u00e8res, ce qui signifie qu'ils peuvent \u00eatre d\u00e9marr\u00e9s et arr\u00eat\u00e9s selon les besoins. Cependant, dans certains cas, vous pouvez vouloir que vos conteneurs red\u00e9marrent automatiquement en cas de d\u00e9faillance ou de red\u00e9marrage du syst\u00e8me. C'est l\u00e0 qu'interviennent les strat\u00e9gies de red\u00e9marrage de Docker.\n\nDocker propose plusieurs strat\u00e9gies de red\u00e9marrage que vous pouvez utiliser pour contr\u00f4ler le comportement de vos conteneurs en cas d'arr\u00eat inattendu ou de red\u00e9marrage du syst\u00e8me. Voici les diff\u00e9rentes options disponibles :\n\n1. no : Cette strat\u00e9gie ne red\u00e9marre jamais le conteneur, m\u00eame s'il s'arr\u00eate de mani\u00e8re inattendue. C'est la valeur par d\u00e9faut.\n\n2. on-failure[:max-retries] : Cette strat\u00e9gie red\u00e9marre le conteneur s'il s'arr\u00eate avec un code de sortie non nul (ce qui indique g\u00e9n\u00e9ralement une erreur). Vous pouvez sp\u00e9cifier le nombre maximum de tentatives de red\u00e9marrage en utilisant l'option max-retries. Par exemple, on-failure:3 limitera le nombre de red\u00e9marrages \u00e0 3.\n\n3. always : Cette strat\u00e9gie red\u00e9marre toujours le conteneur, peu importe le code de sortie. Si le conteneur est arr\u00eat\u00e9 manuellement, il sera red\u00e9marr\u00e9 lorsqu'il d\u00e9tectera que le d\u00e9mon Docker a red\u00e9marr\u00e9.\n\n4. unless-stopped : Cette strat\u00e9gie est similaire \u00e0 always, mais elle ne red\u00e9marre pas le conteneur s'il a \u00e9t\u00e9 arr\u00eat\u00e9 manuellement. Si le conteneur est arr\u00eat\u00e9 manuellement, il restera arr\u00eat\u00e9 jusqu'\u00e0 ce qu'il soit d\u00e9marr\u00e9 manuellement ou que le d\u00e9mon Docker red\u00e9marre.\n\nPour configurer une strat\u00e9gie de red\u00e9marrage pour un conteneur, vous pouvez utiliser l'option --restart lors de l'ex\u00e9cution de la commande docker run. Par exemple, pour d\u00e9marrer un conteneur avec la strat\u00e9gie de red\u00e9marrage always, vous pouvez utiliser la commande suivante :\n\n```\ndocker run --restart=always nginx\n```\n\nDans cet exemple, nous d\u00e9marrons un conteneur bas\u00e9 sur l'image nginx avec la strat\u00e9gie de red\u00e9marrage always. Cela signifie que le conteneur sera toujours red\u00e9marr\u00e9, peu importe le code de sortie.\n\nVous pouvez \u00e9galement modifier la strat\u00e9gie de red\u00e9marrage d'un conteneur existant en utilisant la commande docker update. Par exemple, pour modifier la strat\u00e9gie de red\u00e9marrage d'un conteneur nomm\u00e9 \"my-container\" en \"on-failure:3\", vous pouvez utiliser la commande suivante :\n\n```\ndocker update --restart=on-failure:3 my-container\n```\n\nDans cet exemple, nous modifions la strat\u00e9gie de red\u00e9marrage du conteneur \"my-container\" en \"on-failure:3\". Cela signifie que le conteneur sera red\u00e9marr\u00e9 jusqu'\u00e0 3 fois s'il s'arr\u00eate avec un code de sortie non nul.\n\nIl est important de noter que les strat\u00e9gies de red\u00e9marrage ne garantissent pas que votre conteneur sera toujours disponible. Elles ne font que contr\u00f4ler le comportement de red\u00e9marrage du conteneur en cas d'arr\u00eat inattendu ou de red\u00e9marrage du syst\u00e8me. Il est toujours recommand\u00e9 de concevoir vos applications de mani\u00e8re \u00e0 ce qu'elles soient r\u00e9silientes et capables de g\u00e9rer les \u00e9checs.\n\nEn conclusion, les strat\u00e9gies de red\u00e9marrage de Docker vous permettent de contr\u00f4ler le comportement de vos conteneurs en cas d'arr\u00eat inattendu ou de red\u00e9marrage du syst\u00e8me. En choisissant la strat\u00e9gie appropri\u00e9e, vous pouvez vous assurer que vos conteneurs sont red\u00e9marr\u00e9s automatiquement lorsque cela est n\u00e9cessaire, ce qui contribue \u00e0 am\u00e9liorer la disponibilit\u00e9 et la fiabilit\u00e9 de vos applications.<\/h1>\n<p>Docker a r\u00e9volutionn\u00e9 la fa\u00e7on dont les d\u00e9veloppeurs construisent, exp\u00e9dient et <span class=\"glossaryai-tooltip glossary-term-672\"><span class=\"glossaryai-link\"><a href=\"https:\/\/dockerpros.com\/fr\/wiki\/run\/\" target=\"_blank\">run<\/a><\/span><span class=\"gai-content-hidden glossaryai-tooltip-content\"><span class=\"gai-tooltip-body\"><span class=\"glossaryai-tooltip-text\">\"RUN\" refers to a command in various programming languages and operating systems to execute a specified program or script. It initiates processes, providing a controlled environment for task execution.<span class=\"glossaryai-more-link\"> <a href=\"https:\/\/dockerpros.com\/fr\/wiki\/run\/\">More \u00bb<\/a><\/span><\/span><\/span><\/span><\/span> applications. Il permet d'encapsuler les applications dans des conteneurs l\u00e9gers, permettant un d\u00e9ploiement coh\u00e9rent dans divers environnements. Cependant, l'un des aspects critiques de l'ex\u00e9cution d'applications en conteneurs est de s'assurer qu'elles sont r\u00e9silientes et peuvent r\u00e9cup\u00e9rer apr\u00e8s des d\u00e9faillances inattendues. C'est l\u00e0 que les strat\u00e9gies de red\u00e9marrage entrent en jeu. Dans cet article, nous plongerons au c\u0153ur de <span class=\"glossaryai-tooltip glossary-term-764\"><span class=\"glossaryai-link\"><a href=\"https:\/\/dockerpros.com\/fr\/wiki\/docker-restart-policies\/\" target=\"_blank\">Docker restart policies<\/a><\/span><span class=\"gai-content-hidden glossaryai-tooltip-content\"><span class=\"gai-tooltip-body\"><span class=\"glossaryai-tooltip-text\">Les strat\u00e9gies de red\u00e9marrage de Docker d\u00e9finissent le comportement des conteneurs lorsqu'ils s'arr\u00eatent ou \u00e9chouent. Les options incluent \" no \", \" always \", \" unless-stopped \" et \" on-failure \", permettant de personnaliser la tol\u00e9rance aux pannes et la fiabilit\u00e9 des services.<span class=\"glossaryai-more-link\"> <a href=\"https:\/\/dockerpros.com\/fr\/wiki\/docker-restart-policies\/\">More \u00bb<\/a><\/span><\/span><\/span><\/span><\/span>, how they work, and best practices for configuring them to ensure robust applications.<\/p>\n<h2>What are Restart Policies?<\/h2>\n<p>In Docker, a restart policy is a set of rules that dictate how a <span class=\"glossaryai-tooltip glossary-term-650\"><span class=\"glossaryai-link\"><a href=\"https:\/\/dockerpros.com\/fr\/wiki\/container\/\" target=\"_blank\">conteneur<\/a><\/span><span class=\"gai-content-hidden glossaryai-tooltip-content\"><span class=\"gai-tooltip-body\"><span class=\"glossaryai-tooltip-text\">Containers are lightweight, portable units that encapsulate software and its dependencies, enabling consistent execution across different environments. They leverage OS-level virtualization for efficiency.<span class=\"glossaryai-more-link\"> <a href=\"https:\/\/dockerpros.com\/fr\/wiki\/container\/\">More \u00bb<\/a><\/span><\/span><\/span><\/span><\/span> should behave when it exits or fails. The primary goal of restart policies is to ensure that the application running inside the <span class=\"glossaryai-tooltip glossary-term-650\"><span class=\"glossaryai-link\"><a href=\"https:\/\/dockerpros.com\/fr\/wiki\/container\/\" target=\"_blank\">conteneur<\/a><\/span><span class=\"gai-content-hidden glossaryai-tooltip-content\"><span class=\"gai-tooltip-body\"><span class=\"glossaryai-tooltip-text\">Containers are lightweight, portable units that encapsulate software and its dependencies, enabling consistent execution across different environments. They leverage OS-level virtualization for efficiency.<span class=\"glossaryai-more-link\"> <a href=\"https:\/\/dockerpros.com\/fr\/wiki\/container\/\">More \u00bb<\/a><\/span><\/span><\/span><\/span><\/span> remains available and operational, even in the face of unexpected errors. Docker provides several built-in restart policies that allow you to control the lifecycle of your containers in response to various exit conditions.<\/p>\n<h2>Pourquoi utiliser les strat\u00e9gies de red\u00e9marrage ?<\/h2>\n<p>Les conteneurs sont par nature \u00e9ph\u00e9m\u00e8res ; ils peuvent s'arr\u00eater et red\u00e9marrer fr\u00e9quemment. Cependant, dans des sc\u00e9narios de production, nous voulons que nos applications soient aussi r\u00e9silientes que possible. L'utilisation de strat\u00e9gies de red\u00e9marrage apporte plusieurs avantages :<\/p>\n<ol>\n<li><strong>Haute Disponibilit\u00e9<\/strong>: En red\u00e9marrant automatiquement les conteneurs, vous pouvez maintenir une haute disponibilit\u00e9 de vos services, r\u00e9duisant ainsi les temps d'arr\u00eat.<\/li>\n<li><strong>Intervention manuelle r\u00e9duite<\/strong>: Les strat\u00e9gies de red\u00e9marrage aident \u00e0 automatiser les processus de r\u00e9cup\u00e9ration, minimisant ainsi le besoin d'intervention manuelle de la part des administrateurs syst\u00e8me.<\/li>\n<li><strong>Fiabilit\u00e9 am\u00e9lior\u00e9e<\/strong>: Ensuring that your containers restart upon failure can help catch transient issues that could otherwise lead to <span class=\"glossaryai-tooltip glossary-term-681\"><span class=\"glossaryai-link\"><a href=\"https:\/\/dockerpros.com\/fr\/wiki\/service\/\" target=\"_blank\">service<\/a><\/span><span class=\"gai-content-hidden glossaryai-tooltip-content\"><span class=\"gai-tooltip-body\"><span class=\"glossaryai-tooltip-text\">Le service fait r\u00e9f\u00e9rence \u00e0 l'acte de fournir une assistance ou un soutien pour r\u00e9pondre \u00e0 des besoins ou des exigences sp\u00e9cifiques. Dans divers domaines, il englobe le service client, le support technique et les services professionnels, en mettant l'accent sur l'efficacit\u00e9 et la satisfaction de l'utilisateur.<span class=\"glossaryai-more-link\"> <a href=\"https:\/\/dockerpros.com\/fr\/wiki\/service\/\">More \u00bb<\/a><\/span><\/span><\/span><\/span><\/span> disruptions.<\/li>\n<\/ol>\n<h2>Docker Restart Policies Overview<\/h2>\n<p>Docker offers several restart policy options, which can be set when building a <span class=\"glossaryai-tooltip glossary-term-650\"><span class=\"glossaryai-link\"><a href=\"https:\/\/dockerpros.com\/fr\/wiki\/container\/\" target=\"_blank\">conteneur<\/a><\/span><span class=\"gai-content-hidden glossaryai-tooltip-content\"><span class=\"gai-tooltip-body\"><span class=\"glossaryai-tooltip-text\">Containers are lightweight, portable units that encapsulate software and its dependencies, enabling consistent execution across different environments. They leverage OS-level virtualization for efficiency.<span class=\"glossaryai-more-link\"> <a href=\"https:\/\/dockerpros.com\/fr\/wiki\/container\/\">More \u00bb<\/a><\/span><\/span><\/span><\/span><\/span> or updated afterward. The available restart policies are:<\/p>\n<ol>\n<li>\n<p><strong>Non (par d\u00e9faut)<\/strong>: Il s'agit du r\u00e9glage par d\u00e9faut. Les conteneurs ne red\u00e9marrent pas automatiquement lorsqu'ils s'arr\u00eatent.<\/p>\n<\/li>\n<li>\n<p><strong>Always<\/strong>: With this policy, Docker will restart the <span class=\"glossaryai-tooltip glossary-term-650\"><span class=\"glossaryai-link\"><a href=\"https:\/\/dockerpros.com\/fr\/wiki\/container\/\" target=\"_blank\">conteneur<\/a><\/span><span class=\"gai-content-hidden glossaryai-tooltip-content\"><span class=\"gai-tooltip-body\"><span class=\"glossaryai-tooltip-text\">Containers are lightweight, portable units that encapsulate software and its dependencies, enabling consistent execution across different environments. They leverage OS-level virtualization for efficiency.<span class=\"glossaryai-more-link\"> <a href=\"https:\/\/dockerpros.com\/fr\/wiki\/container\/\">More \u00bb<\/a><\/span><\/span><\/span><\/span><\/span> indefinitely, irrespective of the exit status. It is particularly useful for long-running services that must always be available.<\/p>\n<\/li>\n<li>\n<p><strong>Unless-stopped<\/strong>: Similar to the <code>always<\/code> policy, this option will restart the <span class=\"glossaryai-tooltip glossary-term-650\"><span class=\"glossaryai-link\"><a href=\"https:\/\/dockerpros.com\/fr\/wiki\/container\/\" target=\"_blank\">conteneur<\/a><\/span><span class=\"gai-content-hidden glossaryai-tooltip-content\"><span class=\"gai-tooltip-body\"><span class=\"glossaryai-tooltip-text\">Containers are lightweight, portable units that encapsulate software and its dependencies, enabling consistent execution across different environments. They leverage OS-level virtualization for efficiency.<span class=\"glossaryai-more-link\"> <a href=\"https:\/\/dockerpros.com\/fr\/wiki\/container\/\">More \u00bb<\/a><\/span><\/span><\/span><\/span><\/span> unless it was explicitly stopped by the user. If the <span class=\"glossaryai-tooltip glossary-term-650\"><span class=\"glossaryai-link\"><a href=\"https:\/\/dockerpros.com\/fr\/wiki\/container\/\" target=\"_blank\">conteneur<\/a><\/span><span class=\"gai-content-hidden glossaryai-tooltip-content\"><span class=\"gai-tooltip-body\"><span class=\"glossaryai-tooltip-text\">Containers are lightweight, portable units that encapsulate software and its dependencies, enabling consistent execution across different environments. They leverage OS-level virtualization for efficiency.<span class=\"glossaryai-more-link\"> <a href=\"https:\/\/dockerpros.com\/fr\/wiki\/container\/\">More \u00bb<\/a><\/span><\/span><\/span><\/span><\/span> is stopped, it won\u2019t restart until the Docker <span class=\"glossaryai-tooltip glossary-term-667\"><span class=\"glossaryai-link\"><a href=\"https:\/\/dockerpros.com\/fr\/wiki\/daemon\/\" target=\"_blank\">d\u00e9mon<\/a><\/span><span class=\"gai-content-hidden glossaryai-tooltip-content\"><span class=\"gai-tooltip-body\"><span class=\"glossaryai-tooltip-text\">Un d\u00e9mon est un processus d'arri\u00e8re-plan en informatique qui s'ex\u00e9cute de mani\u00e8re autonome, effectuant des t\u00e2ches sans intervention de l'utilisateur. Il g\u00e8re g\u00e9n\u00e9ralement des fonctions au niveau du syst\u00e8me ou de l'application, am\u00e9liorant ainsi l'efficacit\u00e9.<span class=\"glossaryai-more-link\"> <a href=\"https:\/\/dockerpros.com\/fr\/wiki\/daemon\/\">More \u00bb<\/a><\/span><\/span><\/span><\/span><\/span> itself is restarted.<\/p>\n<\/li>\n<li>\n<p><strong>On-failure<\/strong>: This policy allows for restarting the <span class=\"glossaryai-tooltip glossary-term-650\"><span class=\"glossaryai-link\"><a href=\"https:\/\/dockerpros.com\/fr\/wiki\/container\/\" target=\"_blank\">conteneur<\/a><\/span><span class=\"gai-content-hidden glossaryai-tooltip-content\"><span class=\"gai-tooltip-body\"><span class=\"glossaryai-tooltip-text\">Containers are lightweight, portable units that encapsulate software and its dependencies, enabling consistent execution across different environments. They leverage OS-level virtualization for efficiency.<span class=\"glossaryai-more-link\"> <a href=\"https:\/\/dockerpros.com\/fr\/wiki\/container\/\">More \u00bb<\/a><\/span><\/span><\/span><\/span><\/span> only if it exits with a non-zero exit status. You can also specify a maximum retry count, after which it will cease to restart the <span class=\"glossaryai-tooltip glossary-term-650\"><span class=\"glossaryai-link\"><a href=\"https:\/\/dockerpros.com\/fr\/wiki\/container\/\" target=\"_blank\">conteneur<\/a><\/span><span class=\"gai-content-hidden glossaryai-tooltip-content\"><span class=\"gai-tooltip-body\"><span class=\"glossaryai-tooltip-text\">Containers are lightweight, portable units that encapsulate software and its dependencies, enabling consistent execution across different environments. They leverage OS-level virtualization for efficiency.<span class=\"glossaryai-more-link\"> <a href=\"https:\/\/dockerpros.com\/fr\/wiki\/container\/\">More \u00bb<\/a><\/span><\/span><\/span><\/span><\/span>.<\/p>\n<\/li>\n<li>\n<p><strong>Avec un nombre maximal de tentatives de reprise<\/strong>C'est une variante de <code>on-failure<\/code> policy where you can specify how many times Docker should attempt to restart the <span class=\"glossaryai-tooltip glossary-term-650\"><span class=\"glossaryai-link\"><a href=\"https:\/\/dockerpros.com\/fr\/wiki\/container\/\" target=\"_blank\">conteneur<\/a><\/span><span class=\"gai-content-hidden glossaryai-tooltip-content\"><span class=\"gai-tooltip-body\"><span class=\"glossaryai-tooltip-text\">Containers are lightweight, portable units that encapsulate software and its dependencies, enabling consistent execution across different environments. They leverage OS-level virtualization for efficiency.<span class=\"glossaryai-more-link\"> <a href=\"https:\/\/dockerpros.com\/fr\/wiki\/container\/\">More \u00bb<\/a><\/span><\/span><\/span><\/span><\/span> before giving up.<\/p>\n<\/li>\n<\/ol>\n<h2>Configuring Restart Policies<\/h2>\n<p>Restart policies can be configured during the <span class=\"glossaryai-tooltip glossary-term-650\"><span class=\"glossaryai-link\"><a href=\"https:\/\/dockerpros.com\/fr\/wiki\/container\/\" target=\"_blank\">conteneur<\/a><\/span><span class=\"gai-content-hidden glossaryai-tooltip-content\"><span class=\"gai-tooltip-body\"><span class=\"glossaryai-tooltip-text\">Containers are lightweight, portable units that encapsulate software and its dependencies, enabling consistent execution across different environments. They leverage OS-level virtualization for efficiency.<span class=\"glossaryai-more-link\"> <a href=\"https:\/\/dockerpros.com\/fr\/wiki\/container\/\">More \u00bb<\/a><\/span><\/span><\/span><\/span><\/span> creation process using the <code>docker <span class=\"glossaryai-tooltip glossary-term-672\"><span class=\"glossaryai-link\"><a href=\"https:\/\/dockerpros.com\/fr\/wiki\/run\/\" target=\"_blank\">run<\/a><\/span><span class=\"gai-content-hidden glossaryai-tooltip-content\"><span class=\"gai-tooltip-body\"><span class=\"glossaryai-tooltip-text\">\"RUN\" refers to a command in various programming languages and operating systems to execute a specified program or script. It initiates processes, providing a controlled environment for task execution.<span class=\"glossaryai-more-link\"> <a href=\"https:\/\/dockerpros.com\/fr\/wiki\/run\/\">More \u00bb<\/a><\/span><\/span><\/span><\/span><\/span><\/code> commande ou en modifiant le <span class=\"glossaryai-tooltip glossary-term-689\"><span class=\"glossaryai-link\"><a href=\"https:\/\/dockerpros.com\/fr\/wiki\/docker-compose-file\/\" target=\"_blank\">fichier Docker Compose<\/a><\/span><span class=\"gai-content-hidden glossaryai-tooltip-content\"><span class=\"gai-tooltip-body\"><span class=\"glossaryai-tooltip-text\">Un fichier Docker Compose est un fichier de configuration YAML qui d\u00e9finit les services, les r\u00e9seaux et les volumes pour les applications Docker multi-conteneurs. Il simplifie le d\u00e9ploiement et la gestion, am\u00e9liorant ainsi l'efficacit\u00e9.<span class=\"glossaryai-more-link\"> <a href=\"https:\/\/dockerpros.com\/fr\/wiki\/docker-compose-file\/\">More \u00bb<\/a><\/span><\/span><\/span><\/span><\/span>. Let\u2019s explore both methods.<\/p>\n<h3>Utilisation de l'interface de ligne de commande Docker<\/h3>\n<p>You can specify a restart policy when you <span class=\"glossaryai-tooltip glossary-term-672\"><span class=\"glossaryai-link\"><a href=\"https:\/\/dockerpros.com\/fr\/wiki\/run\/\" target=\"_blank\">run<\/a><\/span><span class=\"gai-content-hidden glossaryai-tooltip-content\"><span class=\"gai-tooltip-body\"><span class=\"glossaryai-tooltip-text\">\"RUN\" refers to a command in various programming languages and operating systems to execute a specified program or script. It initiates processes, providing a controlled environment for task execution.<span class=\"glossaryai-more-link\"> <a href=\"https:\/\/dockerpros.com\/fr\/wiki\/run\/\">More \u00bb<\/a><\/span><\/span><\/span><\/span><\/span> a <span class=\"glossaryai-tooltip glossary-term-650\"><span class=\"glossaryai-link\"><a href=\"https:\/\/dockerpros.com\/fr\/wiki\/container\/\" target=\"_blank\">conteneur<\/a><\/span><span class=\"gai-content-hidden glossaryai-tooltip-content\"><span class=\"gai-tooltip-body\"><span class=\"glossaryai-tooltip-text\">Containers are lightweight, portable units that encapsulate software and its dependencies, enabling consistent execution across different environments. They leverage OS-level virtualization for efficiency.<span class=\"glossaryai-more-link\"> <a href=\"https:\/\/dockerpros.com\/fr\/wiki\/container\/\">More \u00bb<\/a><\/span><\/span><\/span><\/span><\/span> en utilisant le <code>--restart<\/code> drapeau. Voici comment proc\u00e9der pour chaque politique :<\/p>\n<ul>\n<li>\n<p><strong>No<\/strong> (default):<\/p>\n<pre><code class=\"language-bash\">docker <span class=\"glossaryai-tooltip glossary-term-672\"><span class=\"glossaryai-link\"><a href=\"https:\/\/dockerpros.com\/fr\/wiki\/run\/\" target=\"_blank\">run<\/a><\/span><span class=\"gai-content-hidden glossaryai-tooltip-content\"><span class=\"gai-tooltip-body\"><span class=\"glossaryai-tooltip-text\">\"RUN\" refers to a command in various programming languages and operating systems to execute a specified program or script. It initiates processes, providing a controlled environment for task execution.<span class=\"glossaryai-more-link\"> <a href=\"https:\/\/dockerpros.com\/fr\/wiki\/run\/\">More \u00bb<\/a><\/span><\/span><\/span><\/span><\/span> --name my-container my-image<\/code><\/pre>\n<\/li>\n<li>\n<p><strong>Always<\/strong>:<\/p>\n<pre><code class=\"language-bash\">docker <span class=\"glossaryai-tooltip glossary-term-672\"><span class=\"glossaryai-link\"><a href=\"https:\/\/dockerpros.com\/fr\/wiki\/run\/\" target=\"_blank\">run<\/a><\/span><span class=\"gai-content-hidden glossaryai-tooltip-content\"><span class=\"gai-tooltip-body\"><span class=\"glossaryai-tooltip-text\">\"RUN\" refers to a command in various programming languages and operating systems to execute a specified program or script. It initiates processes, providing a controlled environment for task execution.<span class=\"glossaryai-more-link\"> <a href=\"https:\/\/dockerpros.com\/fr\/wiki\/run\/\">More \u00bb<\/a><\/span><\/span><\/span><\/span><\/span> --restart always --name my-container my-image<\/code><\/pre>\n<\/li>\n<li>\n<p><strong>Unless-stopped<\/strong>:<\/p>\n<pre><code class=\"language-bash\">docker <span class=\"glossaryai-tooltip glossary-term-672\"><span class=\"glossaryai-link\"><a href=\"https:\/\/dockerpros.com\/fr\/wiki\/run\/\" target=\"_blank\">run<\/a><\/span><span class=\"gai-content-hidden glossaryai-tooltip-content\"><span class=\"gai-tooltip-body\"><span class=\"glossaryai-tooltip-text\">\"RUN\" refers to a command in various programming languages and operating systems to execute a specified program or script. It initiates processes, providing a controlled environment for task execution.<span class=\"glossaryai-more-link\"> <a href=\"https:\/\/dockerpros.com\/fr\/wiki\/run\/\">More \u00bb<\/a><\/span><\/span><\/span><\/span><\/span> --restart unless-stopped --name my-container my-image<\/code><\/pre>\n<\/li>\n<li>\n<p><strong>On-failure<\/strong>:<\/p>\n<pre><code class=\"language-bash\">docker <span class=\"glossaryai-tooltip glossary-term-672\"><span class=\"glossaryai-link\"><a href=\"https:\/\/dockerpros.com\/fr\/wiki\/run\/\" target=\"_blank\">run<\/a><\/span><span class=\"gai-content-hidden glossaryai-tooltip-content\"><span class=\"gai-tooltip-body\"><span class=\"glossaryai-tooltip-text\">\"RUN\" refers to a command in various programming languages and operating systems to execute a specified program or script. It initiates processes, providing a controlled environment for task execution.<span class=\"glossaryai-more-link\"> <a href=\"https:\/\/dockerpros.com\/fr\/wiki\/run\/\">More \u00bb<\/a><\/span><\/span><\/span><\/span><\/span> --restart on-failure --name my-container my-image<\/code><\/pre>\n<\/li>\n<li>\n<p><strong>Avec un nombre maximal de tentatives de reprise<\/strong> (Par exemple, 5 tentatives) :<\/p>\n<pre><code class=\"language-bash\">docker <span class=\"glossaryai-tooltip glossary-term-672\"><span class=\"glossaryai-link\"><a href=\"https:\/\/dockerpros.com\/fr\/wiki\/run\/\" target=\"_blank\">run<\/a><\/span><span class=\"gai-content-hidden glossaryai-tooltip-content\"><span class=\"gai-tooltip-body\"><span class=\"glossaryai-tooltip-text\">\"RUN\" refers to a command in various programming languages and operating systems to execute a specified program or script. It initiates processes, providing a controlled environment for task execution.<span class=\"glossaryai-more-link\"> <a href=\"https:\/\/dockerpros.com\/fr\/wiki\/run\/\">More \u00bb<\/a><\/span><\/span><\/span><\/span><\/span> --restart on-failure:5 --name my-container my-image<\/code><\/pre>\n<\/li>\n<\/ul>\n<h3>Utilisation de Docker Compose<\/h3>\n<p>If you\u2019re using <span class=\"glossaryai-tooltip glossary-term-654\"><span class=\"glossaryai-link\"><a href=\"https:\/\/dockerpros.com\/fr\/wiki\/docker-compose\/\" target=\"_blank\">Docker Compose<\/a><\/span><span class=\"gai-content-hidden glossaryai-tooltip-content\"><span class=\"gai-tooltip-body\"><span class=\"glossaryai-tooltip-text\">Docker Compose is a tool for defining and running multi-container Docker applications using a YAML file. It simplifies deployment, configuration, and orchestration of services, enhancing development efficiency.<span class=\"glossaryai-more-link\"> <a href=\"https:\/\/dockerpros.com\/fr\/wiki\/docker-compose\/\">More \u00bb<\/a><\/span><\/span><\/span><\/span><\/span> pour g\u00e9rer vos applications multi-conteneurs, vous pouvez configurer la politique de red\u00e9marrage dans le <code>docker-compose.yml<\/code> Voici un exemple :<\/p>\n<pre><code class=\"language-yaml\">version: '3.8'\nservices:\n  mon-service:\n    <span class=\"glossaryai-tooltip glossary-term-651\"><span class=\"glossaryai-link\"><a href=\"https:\/\/dockerpros.com\/fr\/wiki\/image\/\" target=\"_blank\">image<\/a><\/span><span class=\"gai-content-hidden glossaryai-tooltip-content\"><span class=\"gai-tooltip-body\"><span class=\"glossaryai-tooltip-text\">Une image est une repr\u00e9sentation visuelle d'un objet ou d'une sc\u00e8ne, g\u00e9n\u00e9ralement compos\u00e9e de pixels dans les formats num\u00e9riques. Elle peut transmettre des informations, susciter des \u00e9motions et faciliter la communication \u00e0 travers diff\u00e9rents m\u00e9dias.<span class=\"glossaryai-more-link\"> <a href=\"https:\/\/dockerpros.com\/fr\/wiki\/image\/\">More \u00bb<\/a><\/span><\/span><\/span><\/span><\/span>: my-image\n    restart: always<\/code><\/pre>\n<p>In this example, the <code>mon-service<\/code> <span class=\"glossaryai-tooltip glossary-term-650\"><span class=\"glossaryai-link\"><a href=\"https:\/\/dockerpros.com\/fr\/wiki\/container\/\" target=\"_blank\">conteneur<\/a><\/span><span class=\"gai-content-hidden glossaryai-tooltip-content\"><span class=\"gai-tooltip-body\"><span class=\"glossaryai-tooltip-text\">Containers are lightweight, portable units that encapsulate software and its dependencies, enabling consistent execution across different environments. They leverage OS-level virtualization for efficiency.<span class=\"glossaryai-more-link\"> <a href=\"https:\/\/dockerpros.com\/fr\/wiki\/container\/\">More \u00bb<\/a><\/span><\/span><\/span><\/span><\/span> will restart automatically whenever it exits.<\/p>\n<h2>Understanding Exit Codes<\/h2>\n<p>Pour utiliser efficacement le <code>on-failure<\/code> policy, it\u2019s crucial to understand the exit codes returned by applications. An exit code of <code>0<\/code> indique g\u00e9n\u00e9ralement une r\u00e9ussite, tandis qu'un code non nul indique une erreur ou un \u00e9chec. En configurant la strat\u00e9gie de red\u00e9marrage comme <code>on-failure<\/code>, Docker will restart the <span class=\"glossaryai-tooltip glossary-term-650\"><span class=\"glossaryai-link\"><a href=\"https:\/\/dockerpros.com\/fr\/wiki\/container\/\" target=\"_blank\">conteneur<\/a><\/span><span class=\"gai-content-hidden glossaryai-tooltip-content\"><span class=\"gai-tooltip-body\"><span class=\"glossaryai-tooltip-text\">Containers are lightweight, portable units that encapsulate software and its dependencies, enabling consistent execution across different environments. They leverage OS-level virtualization for efficiency.<span class=\"glossaryai-more-link\"> <a href=\"https:\/\/dockerpros.com\/fr\/wiki\/container\/\">More \u00bb<\/a><\/span><\/span><\/span><\/span><\/span> only when the application exits with a non-zero exit code.<\/p>\n<h3>Custom Exit Codes<\/h3>\n<p>For applications that can return custom exit codes, you can implement logic in your application to signal failure or success. For instance, a web server might return a non-zero exit code when it encounters an unrecoverable error, prompting Docker to restart it.<\/p>\n<h2>Surveillance du comportement de red\u00e9marrage<\/h2>\n<p>Lors de l'utilisation de strat\u00e9gies de red\u00e9marrage, il est essentiel de surveiller le comportement de vos conteneurs. Vous pouvez utiliser le <code>docker ps<\/code> command to see the status of all running containers, which will indicate if a <span class=\"glossaryai-tooltip glossary-term-650\"><span class=\"glossaryai-link\"><a href=\"https:\/\/dockerpros.com\/fr\/wiki\/container\/\" target=\"_blank\">conteneur<\/a><\/span><span class=\"gai-content-hidden glossaryai-tooltip-content\"><span class=\"gai-tooltip-body\"><span class=\"glossaryai-tooltip-text\">Containers are lightweight, portable units that encapsulate software and its dependencies, enabling consistent execution across different environments. They leverage OS-level virtualization for efficiency.<span class=\"glossaryai-more-link\"> <a href=\"https:\/\/dockerpros.com\/fr\/wiki\/container\/\">More \u00bb<\/a><\/span><\/span><\/span><\/span><\/span> has been restarted.<\/p>\n<pre><code class=\"language-bash\">docker ps -a<\/code><\/pre>\n<p>This command will show you the state of each <span class=\"glossaryai-tooltip glossary-term-650\"><span class=\"glossaryai-link\"><a href=\"https:\/\/dockerpros.com\/fr\/wiki\/container\/\" target=\"_blank\">conteneur<\/a><\/span><span class=\"gai-content-hidden glossaryai-tooltip-content\"><span class=\"gai-tooltip-body\"><span class=\"glossaryai-tooltip-text\">Containers are lightweight, portable units that encapsulate software and its dependencies, enabling consistent execution across different environments. They leverage OS-level virtualization for efficiency.<span class=\"glossaryai-more-link\"> <a href=\"https:\/\/dockerpros.com\/fr\/wiki\/container\/\">More \u00bb<\/a><\/span><\/span><\/span><\/span><\/span>, including how many times it has restarted. If you notice that a <span class=\"glossaryai-tooltip glossary-term-650\"><span class=\"glossaryai-link\"><a href=\"https:\/\/dockerpros.com\/fr\/wiki\/container\/\" target=\"_blank\">conteneur<\/a><\/span><span class=\"gai-content-hidden glossaryai-tooltip-content\"><span class=\"gai-tooltip-body\"><span class=\"glossaryai-tooltip-text\">Containers are lightweight, portable units that encapsulate software and its dependencies, enabling consistent execution across different environments. They leverage OS-level virtualization for efficiency.<span class=\"glossaryai-more-link\"> <a href=\"https:\/\/dockerpros.com\/fr\/wiki\/container\/\">More \u00bb<\/a><\/span><\/span><\/span><\/span><\/span> is restarting frequently, it may indicate an underlying issue with your application that needs to be addressed.<\/p>\n<h2>Limitations and Considerations<\/h2>\n<p>While restart policies are powerful tools for managing <span class=\"glossaryai-tooltip glossary-term-650\"><span class=\"glossaryai-link\"><a href=\"https:\/\/dockerpros.com\/fr\/wiki\/container\/\" target=\"_blank\">conteneur<\/a><\/span><span class=\"gai-content-hidden glossaryai-tooltip-content\"><span class=\"gai-tooltip-body\"><span class=\"glossaryai-tooltip-text\">Containers are lightweight, portable units that encapsulate software and its dependencies, enabling consistent execution across different environments. They leverage OS-level virtualization for efficiency.<span class=\"glossaryai-more-link\"> <a href=\"https:\/\/dockerpros.com\/fr\/wiki\/container\/\">More \u00bb<\/a><\/span><\/span><\/span><\/span><\/span> lifecycles, there are some limitations and considerations to keep in mind:<\/p>\n<ol>\n<li>\n<p><strong>Boucles infinies<\/strong>: If a <span class=\"glossaryai-tooltip glossary-term-650\"><span class=\"glossaryai-link\"><a href=\"https:\/\/dockerpros.com\/fr\/wiki\/container\/\" target=\"_blank\">conteneur<\/a><\/span><span class=\"gai-content-hidden glossaryai-tooltip-content\"><span class=\"gai-tooltip-body\"><span class=\"glossaryai-tooltip-text\">Containers are lightweight, portable units that encapsulate software and its dependencies, enabling consistent execution across different environments. They leverage OS-level virtualization for efficiency.<span class=\"glossaryai-more-link\"> <a href=\"https:\/\/dockerpros.com\/fr\/wiki\/container\/\">More \u00bb<\/a><\/span><\/span><\/span><\/span><\/span> continuously fails and restarts, it may lead to an infinite restart loop, consuming system resources. It\u2019s essential to investigate the root cause of the failure.<\/p>\n<\/li>\n<li>\n<p><strong>Statefulness<\/strong>: Restarting containers can lead to data loss if the application is not designed to handle state properly. Consider using persistent storage solutions, such as Docker volumes, to maintain data across <span class=\"glossaryai-tooltip glossary-term-650\"><span class=\"glossaryai-link\"><a href=\"https:\/\/dockerpros.com\/fr\/wiki\/container\/\" target=\"_blank\">conteneur<\/a><\/span><span class=\"gai-content-hidden glossaryai-tooltip-content\"><span class=\"gai-tooltip-body\"><span class=\"glossaryai-tooltip-text\">Containers are lightweight, portable units that encapsulate software and its dependencies, enabling consistent execution across different environments. They leverage OS-level virtualization for efficiency.<span class=\"glossaryai-more-link\"> <a href=\"https:\/\/dockerpros.com\/fr\/wiki\/container\/\">More \u00bb<\/a><\/span><\/span><\/span><\/span><\/span> restarts.<\/p>\n<\/li>\n<li>\n<p><strong>Surveillance et alertes<\/strong>Mettez en place des solutions de surveillance pour suivre l'\u00e9tat de sant\u00e9 de vos conteneurs, ce qui peut vous aider \u00e0 anticiper et r\u00e9soudre les probl\u00e8mes avant qu'ils ne provoquent des indisponibilit\u00e9s.<\/p>\n<\/li>\n<li>\n<p><strong><span class=\"glossaryai-tooltip glossary-term-681\"><span class=\"glossaryai-link\"><a href=\"https:\/\/dockerpros.com\/fr\/wiki\/service\/\" target=\"_blank\">Service<\/a><\/span><span class=\"gai-content-hidden glossaryai-tooltip-content\"><span class=\"gai-tooltip-body\"><span class=\"glossaryai-tooltip-text\">Le service fait r\u00e9f\u00e9rence \u00e0 l'acte de fournir une assistance ou un soutien pour r\u00e9pondre \u00e0 des besoins ou des exigences sp\u00e9cifiques. Dans divers domaines, il englobe le service client, le support technique et les services professionnels, en mettant l'accent sur l'efficacit\u00e9 et la satisfaction de l'utilisateur.<span class=\"glossaryai-more-link\"> <a href=\"https:\/\/dockerpros.com\/fr\/wiki\/service\/\">More \u00bb<\/a><\/span><\/span><\/span><\/span><\/span> D\u00e9pendances<\/strong>Si vous avez plusieurs services interconnect\u00e9s, assurez-vous qu'ils sont capables de g\u00e9rer les red\u00e9marrages proprement. Utilisez <span class=\"glossaryai-tooltip glossary-term-657\"><span class=\"glossaryai-link\"><a href=\"https:\/\/dockerpros.com\/fr\/wiki\/orchestration\/\" target=\"_blank\">orchestration<\/a><\/span><span class=\"gai-content-hidden glossaryai-tooltip-content\"><span class=\"gai-tooltip-body\"><span class=\"glossaryai-tooltip-text\">L'orchestration d\u00e9signe la gestion et la coordination automatis\u00e9es de syst\u00e8mes et de services complexes. Elle optimise les processus en int\u00e9grant diverses composantes, en garantissant un fonctionnement efficace et une utilisation optimale des ressources.<span class=\"glossaryai-more-link\"> <a href=\"https:\/\/dockerpros.com\/fr\/wiki\/orchestration\/\">More \u00bb<\/a><\/span><\/span><\/span><\/span><\/span> des outils comme <span class=\"glossaryai-tooltip glossary-term-656\"><span class=\"glossaryai-link\"><a href=\"https:\/\/dockerpros.com\/fr\/wiki\/kubernetes\/\" target=\"_blank\">Kubernetes<\/a><\/span><span class=\"gai-content-hidden glossaryai-tooltip-content\"><span class=\"gai-tooltip-body\"><span class=\"glossaryai-tooltip-text\">Kubernetes is an open-source container orchestration platform that automates the deployment, scaling, and management of containerized applications, enhancing resource efficiency and resilience.<span class=\"glossaryai-more-link\"> <a href=\"https:\/\/dockerpros.com\/fr\/wiki\/kubernetes\/\">More \u00bb<\/a><\/span><\/span><\/span><\/span><\/span> Pour les architectures complexes qui n\u00e9cessitent une gestion avanc\u00e9e.<\/p>\n<\/li>\n<\/ol>\n<h2>Best Practices for Configuring Restart Policies<\/h2>\n<ol>\n<li>\n<p><strong>Evaluate Application Characteristics<\/strong>: Understand the expected behavior of your application under failure conditions. Use the appropriate restart policy based on how critical the application is.<\/p>\n<\/li>\n<li>\n<p><strong>Implement Logging<\/strong>: Use logging mechanisms to capture errors and exit codes. This can help you diagnose issues that lead to <span class=\"glossaryai-tooltip glossary-term-650\"><span class=\"glossaryai-link\"><a href=\"https:\/\/dockerpros.com\/fr\/wiki\/container\/\" target=\"_blank\">conteneur<\/a><\/span><span class=\"gai-content-hidden glossaryai-tooltip-content\"><span class=\"gai-tooltip-body\"><span class=\"glossaryai-tooltip-text\">Containers are lightweight, portable units that encapsulate software and its dependencies, enabling consistent execution across different environments. They leverage OS-level virtualization for efficiency.<span class=\"glossaryai-more-link\"> <a href=\"https:\/\/dockerpros.com\/fr\/wiki\/container\/\">More \u00bb<\/a><\/span><\/span><\/span><\/span><\/span> exits.<\/p>\n<\/li>\n<li>\n<p><strong>Tester les strat\u00e9gies en d\u00e9veloppement<\/strong>: Before deploying to production, test your restart policies in a staging environment. Simulate failure scenarios to ensure that your policies work as expected.<\/p>\n<\/li>\n<li>\n<p><strong>Use Health Checks<\/strong>: Combine restart policies with health checks. Docker supports health checks that can help determine the state of a <span class=\"glossaryai-tooltip glossary-term-650\"><span class=\"glossaryai-link\"><a href=\"https:\/\/dockerpros.com\/fr\/wiki\/container\/\" target=\"_blank\">conteneur<\/a><\/span><span class=\"gai-content-hidden glossaryai-tooltip-content\"><span class=\"gai-tooltip-body\"><span class=\"glossaryai-tooltip-text\">Containers are lightweight, portable units that encapsulate software and its dependencies, enabling consistent execution across different environments. They leverage OS-level virtualization for efficiency.<span class=\"glossaryai-more-link\"> <a href=\"https:\/\/dockerpros.com\/fr\/wiki\/container\/\">More \u00bb<\/a><\/span><\/span><\/span><\/span><\/span>. If a <span class=\"glossaryai-tooltip glossary-term-698\"><span class=\"glossaryai-link\"><a href=\"https:\/\/dockerpros.com\/fr\/wiki\/health-check\/\" target=\"_blank\">health check<\/a><\/span><span class=\"gai-content-hidden glossaryai-tooltip-content\"><span class=\"gai-tooltip-body\"><span class=\"glossaryai-tooltip-text\">A health check is a systematic evaluation of an individual's physical and mental well-being, often involving assessments of vital signs, medical history, and lifestyle factors to identify potential health risks.<span class=\"glossaryai-more-link\"> <a href=\"https:\/\/dockerpros.com\/fr\/wiki\/health-check\/\">More \u00bb<\/a><\/span><\/span><\/span><\/span><\/span> fails, you may want to stop or restart the <span class=\"glossaryai-tooltip glossary-term-650\"><span class=\"glossaryai-link\"><a href=\"https:\/\/dockerpros.com\/fr\/wiki\/container\/\" target=\"_blank\">conteneur<\/a><\/span><span class=\"gai-content-hidden glossaryai-tooltip-content\"><span class=\"gai-tooltip-body\"><span class=\"glossaryai-tooltip-text\">Containers are lightweight, portable units that encapsulate software and its dependencies, enabling consistent execution across different environments. They leverage OS-level virtualization for efficiency.<span class=\"glossaryai-more-link\"> <a href=\"https:\/\/dockerpros.com\/fr\/wiki\/container\/\">More \u00bb<\/a><\/span><\/span><\/span><\/span><\/span>.<\/p>\n<\/li>\n<li>\n<p><strong>Surveiller les ressources du syst\u00e8me<\/strong>Surveillez les ressources syst\u00e8me pour \u00e9viter de surcharger votre machine h\u00f4te avec trop de red\u00e9marrages. Configurez des limites afin d'\u00e9viter l'\u00e9puisement des ressources.<\/p>\n<\/li>\n<\/ol>\n<h2>Conclusion<\/h2>\n<p><span class=\"glossaryai-tooltip glossary-term-764\"><span class=\"glossaryai-link\"><a href=\"https:\/\/dockerpros.com\/fr\/wiki\/docker-restart-policies\/\" target=\"_blank\">Docker restart policies<\/a><\/span><span class=\"gai-content-hidden glossaryai-tooltip-content\"><span class=\"gai-tooltip-body\"><span class=\"glossaryai-tooltip-text\">Les strat\u00e9gies de red\u00e9marrage de Docker d\u00e9finissent le comportement des conteneurs lorsqu'ils s'arr\u00eatent ou \u00e9chouent. Les options incluent \" no \", \" always \", \" unless-stopped \" et \" on-failure \", permettant de personnaliser la tol\u00e9rance aux pannes et la fiabilit\u00e9 des services.<span class=\"glossaryai-more-link\"> <a href=\"https:\/\/dockerpros.com\/fr\/wiki\/docker-restart-policies\/\">More \u00bb<\/a><\/span><\/span><\/span><\/span><\/span> are powerful tools for managing the lifecycle of containers, ensuring that your applications remain available and resilient. By understanding how restart policies work and configuring them effectively, you can significantly enhance the reliability of your Dockerized applications. However, it\u2019s essential to monitor the behavior of your containers and address underlying issues that may lead to frequent restarts. With proper implementation and monitoring, your applications can thrive in a containerized environment, providing consistent and reliable services to users.<\/p>","protected":false},"excerpt":{"rendered":"<p>Pour configurer les strat\u00e9gies de red\u00e9marrage dans Docker, utilisez le drapeau `\u2013restart` avec des options telles que `no`, `always`, `unless-stopped`, ou `on-failure` lors de <span class=\"glossaryai-tooltip glossary-term-650\"><span class=\"glossaryai-link\"><a href=\"https:\/\/dockerpros.com\/fr\/wiki\/container\/\" target=\"_blank\">conteneur<\/a><\/span><span class=\"gai-content-hidden glossaryai-tooltip-content\"><span class=\"gai-tooltip-body\"><span class=\"glossaryai-tooltip-text\">Containers are lightweight, portable units that encapsulate software and its dependencies, enabling consistent execution across different environments. They leverage OS-level virtualization for efficiency.<span class=\"glossaryai-more-link\"> <a href=\"https:\/\/dockerpros.com\/fr\/wiki\/container\/\">More \u00bb<\/a><\/span><\/span><\/span><\/span><\/span> cr\u00e9ation. Cela garantit que les conteneurs red\u00e9marrent en fonction des conditions sp\u00e9cifi\u00e9es.<\/p>","protected":false},"author":1,"featured_media":384,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[18],"tags":[],"class_list":["post-176","post","type-post","status-publish","format-standard","has-post-thumbnail","hentry","category-installation-and-configuration"],"yoast_head":"<!-- This site is optimized with the Yoast SEO plugin v27.0 - https:\/\/yoast.com\/product\/yoast-seo-wordpress\/ -->\n<title>How do I configure restart policies in Docker? - Dockerpros<\/title>\n<meta name=\"robots\" content=\"index, follow, max-snippet:-1, max-image-preview:large, max-video-preview:-1\" \/>\n<link rel=\"canonical\" href=\"https:\/\/dockerpros.com\/fr\/installation-and-configuration\/comment-configurer-les-strategies-de-redemarrage-dans-docker-vous-pouvez-definir-une-strategie-de-redemarrage-lors-de-lexecution-dun-conteneur-avec-loption-restart-bashdocker-run-re\/\" \/>\n<meta property=\"og:locale\" content=\"fr_FR\" \/>\n<meta property=\"og:type\" content=\"article\" \/>\n<meta property=\"og:title\" content=\"How do I configure restart policies in Docker? - Dockerpros\" \/>\n<meta property=\"og:description\" content=\"To configure restart policies in Docker, use the `--restart` flag with options like `no`, `always`, `unless-stopped`, or `on-failure` during container creation. This ensures containers restart based on specified conditions.\" \/>\n<meta property=\"og:url\" content=\"https:\/\/dockerpros.com\/fr\/installation-and-configuration\/comment-configurer-les-strategies-de-redemarrage-dans-docker-vous-pouvez-definir-une-strategie-de-redemarrage-lors-de-lexecution-dun-conteneur-avec-loption-restart-bashdocker-run-re\/\" \/>\n<meta property=\"og:site_name\" content=\"Dockerpros\" \/>\n<meta property=\"article:published_time\" content=\"2024-07-21T11:53:58+00:00\" \/>\n<meta property=\"og:image\" content=\"https:\/\/dockerpros.com\/wp-content\/uploads\/2024\/07\/how-do-i-configure-restart-policies-in-docker_176.jpg\" \/>\n\t<meta property=\"og:image:width\" content=\"800\" \/>\n\t<meta property=\"og:image:height\" content=\"600\" \/>\n\t<meta property=\"og:image:type\" content=\"image\/jpeg\" \/>\n<meta name=\"author\" content=\"dockerpros\" \/>\n<meta name=\"twitter:card\" content=\"summary_large_image\" \/>\n<meta name=\"twitter:label1\" content=\"\u00c9crit par\" \/>\n\t<meta name=\"twitter:data1\" content=\"dockerpros\" \/>\n\t<meta name=\"twitter:label2\" content=\"Dur\u00e9e de lecture estim\u00e9e\" \/>\n\t<meta name=\"twitter:data2\" content=\"6 minutes\" \/>\n<script type=\"application\/ld+json\" class=\"yoast-schema-graph\">{\"@context\":\"https:\/\/schema.org\",\"@graph\":[{\"@type\":\"Article\",\"@id\":\"https:\/\/dockerpros.com\/installation-and-configuration\/how-do-i-configure-restart-policies-in-docker\/#article\",\"isPartOf\":{\"@id\":\"https:\/\/dockerpros.com\/installation-and-configuration\/how-do-i-configure-restart-policies-in-docker\/\"},\"author\":{\"name\":\"dockerpros\",\"@id\":\"https:\/\/dockerpros.com\/#\/schema\/person\/a9b4c3d7f7a8e2b072e77d47b382a3a4\"},\"headline\":\"How do I configure restart policies in Docker?\",\"datePublished\":\"2024-07-21T11:53:58+00:00\",\"mainEntityOfPage\":{\"@id\":\"https:\/\/dockerpros.com\/installation-and-configuration\/how-do-i-configure-restart-policies-in-docker\/\"},\"wordCount\":1078,\"commentCount\":0,\"publisher\":{\"@id\":\"https:\/\/dockerpros.com\/#organization\"},\"image\":{\"@id\":\"https:\/\/dockerpros.com\/installation-and-configuration\/how-do-i-configure-restart-policies-in-docker\/#primaryimage\"},\"thumbnailUrl\":\"https:\/\/dockerpros.com\/wp-content\/uploads\/2024\/07\/how-do-i-configure-restart-policies-in-docker_176.jpg\",\"articleSection\":[\"Installation and Configuration\"],\"inLanguage\":\"fr-FR\",\"potentialAction\":[{\"@type\":\"CommentAction\",\"name\":\"Comment\",\"target\":[\"https:\/\/dockerpros.com\/installation-and-configuration\/how-do-i-configure-restart-policies-in-docker\/#respond\"]}]},{\"@type\":\"WebPage\",\"@id\":\"https:\/\/dockerpros.com\/installation-and-configuration\/how-do-i-configure-restart-policies-in-docker\/\",\"url\":\"https:\/\/dockerpros.com\/installation-and-configuration\/how-do-i-configure-restart-policies-in-docker\/\",\"name\":\"How do I configure restart policies in Docker? - Dockerpros\",\"isPartOf\":{\"@id\":\"https:\/\/dockerpros.com\/#website\"},\"primaryImageOfPage\":{\"@id\":\"https:\/\/dockerpros.com\/installation-and-configuration\/how-do-i-configure-restart-policies-in-docker\/#primaryimage\"},\"image\":{\"@id\":\"https:\/\/dockerpros.com\/installation-and-configuration\/how-do-i-configure-restart-policies-in-docker\/#primaryimage\"},\"thumbnailUrl\":\"https:\/\/dockerpros.com\/wp-content\/uploads\/2024\/07\/how-do-i-configure-restart-policies-in-docker_176.jpg\",\"datePublished\":\"2024-07-21T11:53:58+00:00\",\"breadcrumb\":{\"@id\":\"https:\/\/dockerpros.com\/installation-and-configuration\/how-do-i-configure-restart-policies-in-docker\/#breadcrumb\"},\"inLanguage\":\"fr-FR\",\"potentialAction\":[{\"@type\":\"ReadAction\",\"target\":[\"https:\/\/dockerpros.com\/installation-and-configuration\/how-do-i-configure-restart-policies-in-docker\/\"]}]},{\"@type\":\"ImageObject\",\"inLanguage\":\"fr-FR\",\"@id\":\"https:\/\/dockerpros.com\/installation-and-configuration\/how-do-i-configure-restart-policies-in-docker\/#primaryimage\",\"url\":\"https:\/\/dockerpros.com\/wp-content\/uploads\/2024\/07\/how-do-i-configure-restart-policies-in-docker_176.jpg\",\"contentUrl\":\"https:\/\/dockerpros.com\/wp-content\/uploads\/2024\/07\/how-do-i-configure-restart-policies-in-docker_176.jpg\",\"width\":800,\"height\":600,\"caption\":\"how-do-i-configure-restart-policies-in-docker-2\"},{\"@type\":\"BreadcrumbList\",\"@id\":\"https:\/\/dockerpros.com\/installation-and-configuration\/how-do-i-configure-restart-policies-in-docker\/#breadcrumb\",\"itemListElement\":[{\"@type\":\"ListItem\",\"position\":1,\"name\":\"Home\",\"item\":\"https:\/\/dockerpros.com\/\"},{\"@type\":\"ListItem\",\"position\":2,\"name\":\"How do I configure restart policies in Docker?\"}]},{\"@type\":\"WebSite\",\"@id\":\"https:\/\/dockerpros.com\/#website\",\"url\":\"https:\/\/dockerpros.com\/\",\"name\":\"Dockerpros\",\"description\":\"DockerPros \u2013 Your Ultimate Docker Resource Hub\",\"publisher\":{\"@id\":\"https:\/\/dockerpros.com\/#organization\"},\"potentialAction\":[{\"@type\":\"SearchAction\",\"target\":{\"@type\":\"EntryPoint\",\"urlTemplate\":\"https:\/\/dockerpros.com\/?s={search_term_string}\"},\"query-input\":{\"@type\":\"PropertyValueSpecification\",\"valueRequired\":true,\"valueName\":\"search_term_string\"}}],\"inLanguage\":\"fr-FR\"},{\"@type\":\"Organization\",\"@id\":\"https:\/\/dockerpros.com\/#organization\",\"name\":\"Dockerpros\",\"url\":\"https:\/\/dockerpros.com\/\",\"logo\":{\"@type\":\"ImageObject\",\"inLanguage\":\"fr-FR\",\"@id\":\"https:\/\/dockerpros.com\/#\/schema\/logo\/image\/\",\"url\":\"https:\/\/dockerpros.com\/wp-content\/uploads\/2024\/07\/Dockerpros_logo_blanco.png\",\"contentUrl\":\"https:\/\/dockerpros.com\/wp-content\/uploads\/2024\/07\/Dockerpros_logo_blanco.png\",\"width\":532,\"height\":114,\"caption\":\"Dockerpros\"},\"image\":{\"@id\":\"https:\/\/dockerpros.com\/#\/schema\/logo\/image\/\"}},{\"@type\":\"Person\",\"@id\":\"https:\/\/dockerpros.com\/#\/schema\/person\/a9b4c3d7f7a8e2b072e77d47b382a3a4\",\"name\":\"dockerpros\",\"image\":{\"@type\":\"ImageObject\",\"inLanguage\":\"fr-FR\",\"@id\":\"https:\/\/dockerpros.com\/#\/schema\/person\/image\/\",\"url\":\"https:\/\/dockerpros.com\/wp-content\/litespeed\/avatar\/d13b9d4f101de1a7535b404e0c59affd.jpg?ver=1781786904\",\"contentUrl\":\"https:\/\/dockerpros.com\/wp-content\/litespeed\/avatar\/d13b9d4f101de1a7535b404e0c59affd.jpg?ver=1781786904\",\"caption\":\"dockerpros\"},\"sameAs\":[\"https:\/\/dockerpros.com\/\"],\"url\":\"https:\/\/dockerpros.com\/fr\/author\/dockerpros\/\"}]}<\/script>\n<!-- \/ Yoast SEO plugin. -->","yoast_head_json":{"title":"How do I configure restart policies in Docker? - Dockerpros","robots":{"index":"index","follow":"follow","max-snippet":"max-snippet:-1","max-image-preview":"max-image-preview:large","max-video-preview":"max-video-preview:-1"},"canonical":"https:\/\/dockerpros.com\/fr\/installation-and-configuration\/comment-configurer-les-strategies-de-redemarrage-dans-docker-vous-pouvez-definir-une-strategie-de-redemarrage-lors-de-lexecution-dun-conteneur-avec-loption-restart-bashdocker-run-re\/","og_locale":"fr_FR","og_type":"article","og_title":"How do I configure restart policies in Docker? - Dockerpros","og_description":"To configure restart policies in Docker, use the `--restart` flag with options like `no`, `always`, `unless-stopped`, or `on-failure` during container creation. This ensures containers restart based on specified conditions.","og_url":"https:\/\/dockerpros.com\/fr\/installation-and-configuration\/comment-configurer-les-strategies-de-redemarrage-dans-docker-vous-pouvez-definir-une-strategie-de-redemarrage-lors-de-lexecution-dun-conteneur-avec-loption-restart-bashdocker-run-re\/","og_site_name":"Dockerpros","article_published_time":"2024-07-21T11:53:58+00:00","og_image":[{"width":800,"height":600,"url":"https:\/\/dockerpros.com\/wp-content\/uploads\/2024\/07\/how-do-i-configure-restart-policies-in-docker_176.jpg","type":"image\/jpeg"}],"author":"dockerpros","twitter_card":"summary_large_image","twitter_misc":{"\u00c9crit par":"dockerpros","Dur\u00e9e de lecture estim\u00e9e":"6 minutes"},"schema":{"@context":"https:\/\/schema.org","@graph":[{"@type":"Article","@id":"https:\/\/dockerpros.com\/installation-and-configuration\/how-do-i-configure-restart-policies-in-docker\/#article","isPartOf":{"@id":"https:\/\/dockerpros.com\/installation-and-configuration\/how-do-i-configure-restart-policies-in-docker\/"},"author":{"name":"dockerpros","@id":"https:\/\/dockerpros.com\/#\/schema\/person\/a9b4c3d7f7a8e2b072e77d47b382a3a4"},"headline":"How do I configure restart policies in Docker?","datePublished":"2024-07-21T11:53:58+00:00","mainEntityOfPage":{"@id":"https:\/\/dockerpros.com\/installation-and-configuration\/how-do-i-configure-restart-policies-in-docker\/"},"wordCount":1078,"commentCount":0,"publisher":{"@id":"https:\/\/dockerpros.com\/#organization"},"image":{"@id":"https:\/\/dockerpros.com\/installation-and-configuration\/how-do-i-configure-restart-policies-in-docker\/#primaryimage"},"thumbnailUrl":"https:\/\/dockerpros.com\/wp-content\/uploads\/2024\/07\/how-do-i-configure-restart-policies-in-docker_176.jpg","articleSection":["Installation and Configuration"],"inLanguage":"fr-FR","potentialAction":[{"@type":"CommentAction","name":"Comment","target":["https:\/\/dockerpros.com\/installation-and-configuration\/how-do-i-configure-restart-policies-in-docker\/#respond"]}]},{"@type":"WebPage","@id":"https:\/\/dockerpros.com\/installation-and-configuration\/how-do-i-configure-restart-policies-in-docker\/","url":"https:\/\/dockerpros.com\/installation-and-configuration\/how-do-i-configure-restart-policies-in-docker\/","name":"How do I configure restart policies in Docker? - Dockerpros","isPartOf":{"@id":"https:\/\/dockerpros.com\/#website"},"primaryImageOfPage":{"@id":"https:\/\/dockerpros.com\/installation-and-configuration\/how-do-i-configure-restart-policies-in-docker\/#primaryimage"},"image":{"@id":"https:\/\/dockerpros.com\/installation-and-configuration\/how-do-i-configure-restart-policies-in-docker\/#primaryimage"},"thumbnailUrl":"https:\/\/dockerpros.com\/wp-content\/uploads\/2024\/07\/how-do-i-configure-restart-policies-in-docker_176.jpg","datePublished":"2024-07-21T11:53:58+00:00","breadcrumb":{"@id":"https:\/\/dockerpros.com\/installation-and-configuration\/how-do-i-configure-restart-policies-in-docker\/#breadcrumb"},"inLanguage":"fr-FR","potentialAction":[{"@type":"ReadAction","target":["https:\/\/dockerpros.com\/installation-and-configuration\/how-do-i-configure-restart-policies-in-docker\/"]}]},{"@type":"ImageObject","inLanguage":"fr-FR","@id":"https:\/\/dockerpros.com\/installation-and-configuration\/how-do-i-configure-restart-policies-in-docker\/#primaryimage","url":"https:\/\/dockerpros.com\/wp-content\/uploads\/2024\/07\/how-do-i-configure-restart-policies-in-docker_176.jpg","contentUrl":"https:\/\/dockerpros.com\/wp-content\/uploads\/2024\/07\/how-do-i-configure-restart-policies-in-docker_176.jpg","width":800,"height":600,"caption":"how-do-i-configure-restart-policies-in-docker-2"},{"@type":"BreadcrumbList","@id":"https:\/\/dockerpros.com\/installation-and-configuration\/how-do-i-configure-restart-policies-in-docker\/#breadcrumb","itemListElement":[{"@type":"ListItem","position":1,"name":"Home","item":"https:\/\/dockerpros.com\/"},{"@type":"ListItem","position":2,"name":"How do I configure restart policies in Docker?"}]},{"@type":"WebSite","@id":"https:\/\/dockerpros.com\/#website","url":"https:\/\/dockerpros.com\/","name":"Dockerpros","description":"DockerPros \u2013 Votre centre de ressources Docker incontournable","publisher":{"@id":"https:\/\/dockerpros.com\/#organization"},"potentialAction":[{"@type":"SearchAction","target":{"@type":"EntryPoint","urlTemplate":"https:\/\/dockerpros.com\/?s={search_term_string}"},"query-input":{"@type":"PropertyValueSpecification","valueRequired":true,"valueName":"search_term_string"}}],"inLanguage":"fr-FR"},{"@type":"Organization","@id":"https:\/\/dockerpros.com\/#organization","name":"Dockerpros","url":"https:\/\/dockerpros.com\/","logo":{"@type":"ImageObject","inLanguage":"fr-FR","@id":"https:\/\/dockerpros.com\/#\/schema\/logo\/image\/","url":"https:\/\/dockerpros.com\/wp-content\/uploads\/2024\/07\/Dockerpros_logo_blanco.png","contentUrl":"https:\/\/dockerpros.com\/wp-content\/uploads\/2024\/07\/Dockerpros_logo_blanco.png","width":532,"height":114,"caption":"Dockerpros"},"image":{"@id":"https:\/\/dockerpros.com\/#\/schema\/logo\/image\/"}},{"@type":"Person","@id":"https:\/\/dockerpros.com\/#\/schema\/person\/a9b4c3d7f7a8e2b072e77d47b382a3a4","name":"professionnels Docker","image":{"@type":"ImageObject","inLanguage":"fr-FR","@id":"https:\/\/dockerpros.com\/#\/schema\/person\/image\/","url":"https:\/\/dockerpros.com\/wp-content\/litespeed\/avatar\/d13b9d4f101de1a7535b404e0c59affd.jpg?ver=1781786904","contentUrl":"https:\/\/dockerpros.com\/wp-content\/litespeed\/avatar\/d13b9d4f101de1a7535b404e0c59affd.jpg?ver=1781786904","caption":"dockerpros"},"sameAs":["https:\/\/dockerpros.com\/"],"url":"https:\/\/dockerpros.com\/fr\/author\/dockerpros\/"}]}},"_links":{"self":[{"href":"https:\/\/dockerpros.com\/fr\/wp-json\/wp\/v2\/posts\/176","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/dockerpros.com\/fr\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/dockerpros.com\/fr\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/dockerpros.com\/fr\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/dockerpros.com\/fr\/wp-json\/wp\/v2\/comments?post=176"}],"version-history":[{"count":0,"href":"https:\/\/dockerpros.com\/fr\/wp-json\/wp\/v2\/posts\/176\/revisions"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/dockerpros.com\/fr\/wp-json\/wp\/v2\/media\/384"}],"wp:attachment":[{"href":"https:\/\/dockerpros.com\/fr\/wp-json\/wp\/v2\/media?parent=176"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/dockerpros.com\/fr\/wp-json\/wp\/v2\/categories?post=176"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/dockerpros.com\/fr\/wp-json\/wp\/v2\/tags?post=176"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}