{"id":764,"date":"2024-07-22T20:40:36","date_gmt":"2024-07-22T20:40:36","guid":{"rendered":"https:\/\/dockerpros.com\/?post_type=glossary&#038;p=764"},"modified":"2024-07-22T20:55:30","modified_gmt":"2024-07-22T20:55:30","slug":"docker-restart-policies","status":"publish","type":"glossary","link":"https:\/\/dockerpros.com\/it\/wiki\/docker-restart-policies\/","title":{"rendered":"Politiche di riavvio di Docker"},"content":{"rendered":"<h1>Understanding Docker Restart Policies: Ensuring Resilience in Containerized Applications<\/h1>\n<p>Docker Restart Policies are a pivotal feature within the Docker ecosystem that govern the behavior of containers in response to failures. These policies enable containers to automatically restart under specified conditions, improving the resiliency and availability of applications deployed in containerized environments. By leveraging Docker Restart Policies, developers and system administrators can ensure that critical services remain operational and recover quickly from unexpected disruptions.<\/p>\n<h2>The Importance of Restart Policies<\/h2>\n<p>In a microservices architecture, where applications are typically composed of multiple interdependent services, the availability of each component is crucial for overall system health. Containers, while lightweight and efficient, can experience failures due to various reasons such as application bugs, resource constraints, or external system issues. This is where Docker Restart Policies come into play. They not only provide a mechanism for recovery but also contribute to the robustness of deploying applications in production environments.<\/p>\n<h3>Types of Restart Policies<\/h3>\n<p>Docker offers several restart policies to accommodate different operational needs:<\/p>\n<ol>\n<li>\n<p><strong>No Restart<\/strong> (<code>--restart=no<\/code>): This is the default policy, which means that if a <span class=\"glossaryai-tooltip glossary-term-650\"><span class=\"glossaryai-link\"><a href=\"https:\/\/dockerpros.com\/it\/wiki\/container\/\" target=\"_blank\">container<\/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\/it\/wiki\/container\/\">More \u00bb<\/a><\/span><\/span><\/span><\/span><\/span> stops, it will not be restarted. This policy is suitable for one-off tasks or containers that are expected to exit without any error.<\/p>\n<\/li>\n<li>\n<p><strong>Always Restart<\/strong> (<code>--restart=always<\/code>): With this policy, Docker will always restart the <span class=\"glossaryai-tooltip glossary-term-650\"><span class=\"glossaryai-link\"><a href=\"https:\/\/dockerpros.com\/it\/wiki\/container\/\" target=\"_blank\">container<\/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\/it\/wiki\/container\/\">More \u00bb<\/a><\/span><\/span><\/span><\/span><\/span> regardless of how it exited\u2014be it due to a failure, a manual stop, or the Docker <span class=\"glossaryai-tooltip glossary-term-667\"><span class=\"glossaryai-link\"><a href=\"https:\/\/dockerpros.com\/it\/wiki\/daemon\/\" target=\"_blank\">daemon<\/a><\/span><span class=\"gai-content-hidden glossaryai-tooltip-content\"><span class=\"gai-tooltip-body\"><span class=\"glossaryai-tooltip-text\">A daemon is a background process in computing that runs autonomously, performing tasks without user intervention. It typically handles system or application-level functions, enhancing efficiency.<span class=\"glossaryai-more-link\"> <a href=\"https:\/\/dockerpros.com\/it\/wiki\/daemon\/\">More \u00bb<\/a><\/span><\/span><\/span><\/span><\/span> restarting. This is often used for long-running services that need to be highly available.<\/p>\n<\/li>\n<li>\n<p><strong>Unless Stopped<\/strong> (<code>--restart=unless-stopped<\/code>): This policy is similar to <code>always<\/code>, but it will not restart the <span class=\"glossaryai-tooltip glossary-term-650\"><span class=\"glossaryai-link\"><a href=\"https:\/\/dockerpros.com\/it\/wiki\/container\/\" target=\"_blank\">container<\/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\/it\/wiki\/container\/\">More \u00bb<\/a><\/span><\/span><\/span><\/span><\/span> if it was explicitly stopped by the user. It allows for manual control while still providing automatic restarts for crashes or <span class=\"glossaryai-tooltip glossary-term-667\"><span class=\"glossaryai-link\"><a href=\"https:\/\/dockerpros.com\/it\/wiki\/daemon\/\" target=\"_blank\">daemon<\/a><\/span><span class=\"gai-content-hidden glossaryai-tooltip-content\"><span class=\"gai-tooltip-body\"><span class=\"glossaryai-tooltip-text\">A daemon is a background process in computing that runs autonomously, performing tasks without user intervention. It typically handles system or application-level functions, enhancing efficiency.<span class=\"glossaryai-more-link\"> <a href=\"https:\/\/dockerpros.com\/it\/wiki\/daemon\/\">More \u00bb<\/a><\/span><\/span><\/span><\/span><\/span> restarts.<\/p>\n<\/li>\n<li>\n<p><strong>On Failure<\/strong> (<code>--restart=on-failure[:max-retries]<\/code>): This policy instructs Docker to restart the <span class=\"glossaryai-tooltip glossary-term-650\"><span class=\"glossaryai-link\"><a href=\"https:\/\/dockerpros.com\/it\/wiki\/container\/\" target=\"_blank\">container<\/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\/it\/wiki\/container\/\">More \u00bb<\/a><\/span><\/span><\/span><\/span><\/span> only if it exits with a non-zero exit code, indicating an error. Additionally, it can limit the number of restart attempts using the <code>max-retries<\/code> parameter, which can be beneficial for managing resources and preventing infinite restart loops.<\/p>\n<\/li>\n<\/ol>\n<h3>Choosing the Right Restart Policy<\/h3>\n<p>Selecting the appropriate restart policy is crucial for ensuring the desired behavior of your containers. The choice depends on the application architecture, user expectations, and operational requirements. Here are some guidelines to help you make an informed decision:<\/p>\n<ul>\n<li>\n<p><strong>For Stateless Services<\/strong>: Use <code>always<\/code> or <code>unless-stopped<\/code> to ensure that your <span class=\"glossaryai-tooltip glossary-term-681\"><span class=\"glossaryai-link\"><a href=\"https:\/\/dockerpros.com\/it\/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\">Service refers to the act of providing assistance or support to fulfill specific needs or requirements. In various domains, it encompasses customer service, technical support, and professional services, emphasizing efficiency and user satisfaction.<span class=\"glossaryai-more-link\"> <a href=\"https:\/\/dockerpros.com\/it\/wiki\/service\/\">More \u00bb<\/a><\/span><\/span><\/span><\/span><\/span> remains available. These policies are suitable for web servers, APIs, and similar applications that need to be up at all times.<\/p>\n<\/li>\n<li>\n<p><strong>For Stateful Services<\/strong>: If your application maintains state, such as databases, you may opt for <code>on-failure<\/code>, especially if you want to avoid unwanted restarts during maintenance or upgrades.<\/p>\n<\/li>\n<li>\n<p><strong>For Batch Jobs<\/strong>: For containers that perform batch processing or scheduled tasks, use <code>no<\/code> as their expected behavior is to exit once their <span class=\"glossaryai-tooltip glossary-term-683\"><span class=\"glossaryai-link\"><a href=\"https:\/\/dockerpros.com\/it\/wiki\/task\/\" target=\"_blank\">task<\/a><\/span><span class=\"gai-content-hidden glossaryai-tooltip-content\"><span class=\"gai-tooltip-body\"><span class=\"glossaryai-tooltip-text\">A task is a specific piece of work or duty assigned to an individual or system. It encompasses defined objectives, required resources, and expected outcomes, facilitating structured progress in various contexts.<span class=\"glossaryai-more-link\"> <a href=\"https:\/\/dockerpros.com\/it\/wiki\/task\/\">More \u00bb<\/a><\/span><\/span><\/span><\/span><\/span> is complete.<\/p>\n<\/li>\n<\/ul>\n<h3>Implementation: Setting Restart Policies in Docker<\/h3>\n<p>Implementing restart policies is straightforward with Docker. You can specify the restart policy during the <span class=\"glossaryai-tooltip glossary-term-650\"><span class=\"glossaryai-link\"><a href=\"https:\/\/dockerpros.com\/it\/wiki\/container\/\" target=\"_blank\">container<\/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\/it\/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\/it\/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\/it\/wiki\/run\/\">More \u00bb<\/a><\/span><\/span><\/span><\/span><\/span><\/code> command or in a <span class=\"glossaryai-tooltip glossary-term-689\"><span class=\"glossaryai-link\"><a href=\"https:\/\/dockerpros.com\/it\/wiki\/docker-compose-file\/\" target=\"_blank\">Docker Compose file<\/a><\/span><span class=\"gai-content-hidden glossaryai-tooltip-content\"><span class=\"gai-tooltip-body\"><span class=\"glossaryai-tooltip-text\">A Docker Compose file is a YAML configuration file that defines services, networks, and volumes for multi-container Docker applications. It streamlines deployment and management, enhancing efficiency.<span class=\"glossaryai-more-link\"> <a href=\"https:\/\/dockerpros.com\/it\/wiki\/docker-compose-file\/\">More \u00bb<\/a><\/span><\/span><\/span><\/span><\/span>.<\/p>\n<h4>Using <code>docker <span class=\"glossaryai-tooltip glossary-term-672\"><span class=\"glossaryai-link\"><a href=\"https:\/\/dockerpros.com\/it\/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\/it\/wiki\/run\/\">More \u00bb<\/a><\/span><\/span><\/span><\/span><\/span><\/code><\/h4>\n<p>Here is an example of how to set a restart policy using the <code>docker <span class=\"glossaryai-tooltip glossary-term-672\"><span class=\"glossaryai-link\"><a href=\"https:\/\/dockerpros.com\/it\/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\/it\/wiki\/run\/\">More \u00bb<\/a><\/span><\/span><\/span><\/span><\/span><\/code> command:<\/p>\n<pre><code class=\"language-bash\">docker <span class=\"glossaryai-tooltip glossary-term-672\"><span class=\"glossaryai-link\"><a href=\"https:\/\/dockerpros.com\/it\/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\/it\/wiki\/run\/\">More \u00bb<\/a><\/span><\/span><\/span><\/span><\/span> -d --restart=always --name my_container my_image<\/code><\/pre>\n<p>In this example, the <span class=\"glossaryai-tooltip glossary-term-650\"><span class=\"glossaryai-link\"><a href=\"https:\/\/dockerpros.com\/it\/wiki\/container\/\" target=\"_blank\">container<\/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\/it\/wiki\/container\/\">More \u00bb<\/a><\/span><\/span><\/span><\/span><\/span> named <code>my_container<\/code> will always restart unless it is stopped manually. <\/p>\n<h4>Using Docker Compose<\/h4>\n<p>In <span class=\"glossaryai-tooltip glossary-term-654\"><span class=\"glossaryai-link\"><a href=\"https:\/\/dockerpros.com\/it\/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\/it\/wiki\/docker-compose\/\">More \u00bb<\/a><\/span><\/span><\/span><\/span><\/span>, you can define restart policies within the <span class=\"glossaryai-tooltip glossary-term-681\"><span class=\"glossaryai-link\"><a href=\"https:\/\/dockerpros.com\/it\/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\">Service refers to the act of providing assistance or support to fulfill specific needs or requirements. In various domains, it encompasses customer service, technical support, and professional services, emphasizing efficiency and user satisfaction.<span class=\"glossaryai-more-link\"> <a href=\"https:\/\/dockerpros.com\/it\/wiki\/service\/\">More \u00bb<\/a><\/span><\/span><\/span><\/span><\/span> configuration. Here\u2019s a sample <code>docker-compose.yml<\/code> file:<\/p>\n<pre><code class=\"language-yaml\">version: '3.8'\n\nservices:\n  web:\n    image: nginx\n    restart: always\n    ports:\n      - \"80:80\"\n\n  app:\n    <span class=\"glossaryai-tooltip glossary-term-651\"><span class=\"glossaryai-link\"><a href=\"https:\/\/dockerpros.com\/it\/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\">An image is a visual representation of an object or scene, typically composed of pixels in digital formats. It can convey information, evoke emotions, and facilitate communication across various media.<span class=\"glossaryai-more-link\"> <a href=\"https:\/\/dockerpros.com\/it\/wiki\/image\/\">More \u00bb<\/a><\/span><\/span><\/span><\/span><\/span>: my_app\n    restart: on-failure:5<\/code><\/pre>\n<p>In this configuration, the <code>web<\/code> <span class=\"glossaryai-tooltip glossary-term-681\"><span class=\"glossaryai-link\"><a href=\"https:\/\/dockerpros.com\/it\/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\">Service refers to the act of providing assistance or support to fulfill specific needs or requirements. In various domains, it encompasses customer service, technical support, and professional services, emphasizing efficiency and user satisfaction.<span class=\"glossaryai-more-link\"> <a href=\"https:\/\/dockerpros.com\/it\/wiki\/service\/\">More \u00bb<\/a><\/span><\/span><\/span><\/span><\/span> will always restart, while the <code>app<\/code> <span class=\"glossaryai-tooltip glossary-term-681\"><span class=\"glossaryai-link\"><a href=\"https:\/\/dockerpros.com\/it\/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\">Service refers to the act of providing assistance or support to fulfill specific needs or requirements. In various domains, it encompasses customer service, technical support, and professional services, emphasizing efficiency and user satisfaction.<span class=\"glossaryai-more-link\"> <a href=\"https:\/\/dockerpros.com\/it\/wiki\/service\/\">More \u00bb<\/a><\/span><\/span><\/span><\/span><\/span> will only restart on failure with a maximum of 5 attempts.<\/p>\n<h3>Monitoring and Managing Restarted Containers<\/h3>\n<p>While restart policies help in maintaining the uptime of your containers, monitoring is essential for understanding the underlying causes of failures. Docker provides several tools and commands to help you keep track of <span class=\"glossaryai-tooltip glossary-term-650\"><span class=\"glossaryai-link\"><a href=\"https:\/\/dockerpros.com\/it\/wiki\/container\/\" target=\"_blank\">container<\/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\/it\/wiki\/container\/\">More \u00bb<\/a><\/span><\/span><\/span><\/span><\/span> health.<\/p>\n<h4>Docker Events<\/h4>\n<p>You can monitor Docker events using the <code>docker events<\/code> command, which provides real-time information about <span class=\"glossaryai-tooltip glossary-term-650\"><span class=\"glossaryai-link\"><a href=\"https:\/\/dockerpros.com\/it\/wiki\/container\/\" target=\"_blank\">container<\/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\/it\/wiki\/container\/\">More \u00bb<\/a><\/span><\/span><\/span><\/span><\/span> state changes, including restarts:<\/p>\n<pre><code class=\"language-bash\">docker events --filter event=restart<\/code><\/pre>\n<p>This command will list all restart events, enabling you to track how often your containers are restarting.<\/p>\n<h4>Logs<\/h4>\n<p>Checking <span class=\"glossaryai-tooltip glossary-term-650\"><span class=\"glossaryai-link\"><a href=\"https:\/\/dockerpros.com\/it\/wiki\/container\/\" target=\"_blank\">container<\/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\/it\/wiki\/container\/\">More \u00bb<\/a><\/span><\/span><\/span><\/span><\/span> logs is another efficient way to diagnose issues. You can use the <code>docker logs<\/code> command to inspect the output of a <span class=\"glossaryai-tooltip glossary-term-650\"><span class=\"glossaryai-link\"><a href=\"https:\/\/dockerpros.com\/it\/wiki\/container\/\" target=\"_blank\">container<\/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\/it\/wiki\/container\/\">More \u00bb<\/a><\/span><\/span><\/span><\/span><\/span>:<\/p>\n<pre><code class=\"language-bash\">docker logs my_container<\/code><\/pre>\n<p>Analyzing logs can shed light on why a <span class=\"glossaryai-tooltip glossary-term-650\"><span class=\"glossaryai-link\"><a href=\"https:\/\/dockerpros.com\/it\/wiki\/container\/\" target=\"_blank\">container<\/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\/it\/wiki\/container\/\">More \u00bb<\/a><\/span><\/span><\/span><\/span><\/span> is exiting unexpectedly and whether the restart policy is functioning as intended.<\/p>\n<h3>The Impact of Restart Policies on Resource Management<\/h3>\n<p>Restarting containers can impact system resources, especially in environments with limited capacity. Understanding the implications of restart policies will help you optimize your resource usage:<\/p>\n<ul>\n<li>\n<p><strong>Resource Exhaustion<\/strong>: A <span class=\"glossaryai-tooltip glossary-term-650\"><span class=\"glossaryai-link\"><a href=\"https:\/\/dockerpros.com\/it\/wiki\/container\/\" target=\"_blank\">container<\/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\/it\/wiki\/container\/\">More \u00bb<\/a><\/span><\/span><\/span><\/span><\/span> that continuously fails and restarts can lead to resource exhaustion (CPU, memory, disk I\/O). To mitigate this, use the <code>on-failure<\/code> policy with a defined maximum number of retries.<\/p>\n<\/li>\n<li>\n<p><strong><span class=\"glossaryai-tooltip glossary-term-657\"><span class=\"glossaryai-link\"><a href=\"https:\/\/dockerpros.com\/it\/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\">Orchestration refers to the automated management and coordination of complex systems and services. It optimizes processes by integrating various components, ensuring efficient operation and resource utilization.<span class=\"glossaryai-more-link\"> <a href=\"https:\/\/dockerpros.com\/it\/wiki\/orchestration\/\">More \u00bb<\/a><\/span><\/span><\/span><\/span><\/span><\/strong>: In orchestrated environments like <span class=\"glossaryai-tooltip glossary-term-656\"><span class=\"glossaryai-link\"><a href=\"https:\/\/dockerpros.com\/it\/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\/it\/wiki\/kubernetes\/\">More \u00bb<\/a><\/span><\/span><\/span><\/span><\/span> or <span class=\"glossaryai-tooltip glossary-term-655\"><span class=\"glossaryai-link\"><a href=\"https:\/\/dockerpros.com\/it\/wiki\/docker-swarm\/\" target=\"_blank\">Docker Swarm<\/a><\/span><span class=\"gai-content-hidden glossaryai-tooltip-content\"><span class=\"gai-tooltip-body\"><span class=\"glossaryai-tooltip-text\">Docker Swarm is a container orchestration tool that enables the management of a cluster of Docker engines. It simplifies scaling and deployment, ensuring high availability and load balancing across services.<span class=\"glossaryai-more-link\"> <a href=\"https:\/\/dockerpros.com\/it\/wiki\/docker-swarm\/\">More \u00bb<\/a><\/span><\/span><\/span><\/span><\/span>, the restart policy may interact with the <span class=\"glossaryai-tooltip glossary-term-657\"><span class=\"glossaryai-link\"><a href=\"https:\/\/dockerpros.com\/it\/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\">Orchestration refers to the automated management and coordination of complex systems and services. It optimizes processes by integrating various components, ensuring efficient operation and resource utilization.<span class=\"glossaryai-more-link\"> <a href=\"https:\/\/dockerpros.com\/it\/wiki\/orchestration\/\">More \u00bb<\/a><\/span><\/span><\/span><\/span><\/span> platform\u2019s health checks and <span class=\"glossaryai-tooltip glossary-term-696\"><span class=\"glossaryai-link\"><a href=\"https:\/\/dockerpros.com\/it\/wiki\/scaling\/\" target=\"_blank\">scaling<\/a><\/span><span class=\"gai-content-hidden glossaryai-tooltip-content\"><span class=\"gai-tooltip-body\"><span class=\"glossaryai-tooltip-text\">Scaling refers to the process of adjusting the capacity of a system to accommodate varying loads. It can be achieved through vertical scaling, which enhances existing resources, or horizontal scaling, which adds additional resources.<span class=\"glossaryai-more-link\"> <a href=\"https:\/\/dockerpros.com\/it\/wiki\/scaling\/\">More \u00bb<\/a><\/span><\/span><\/span><\/span><\/span> capabilities. Ensure that you understand how these systems work together to avoid conflicts.<\/p>\n<\/li>\n<\/ul>\n<h3>Advanced Scenarios: Combining Restart Policies with Health Checks<\/h3>\n<p>Docker\u2019s restart policies work effectively in conjunction with <span class=\"glossaryai-tooltip glossary-term-650\"><span class=\"glossaryai-link\"><a href=\"https:\/\/dockerpros.com\/it\/wiki\/container\/\" target=\"_blank\">container<\/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\/it\/wiki\/container\/\">More \u00bb<\/a><\/span><\/span><\/span><\/span><\/span> health checks. Health checks allow you to define conditions under which a <span class=\"glossaryai-tooltip glossary-term-650\"><span class=\"glossaryai-link\"><a href=\"https:\/\/dockerpros.com\/it\/wiki\/container\/\" target=\"_blank\">container<\/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\/it\/wiki\/container\/\">More \u00bb<\/a><\/span><\/span><\/span><\/span><\/span> is considered to be healthy or unhealthy. If a <span class=\"glossaryai-tooltip glossary-term-650\"><span class=\"glossaryai-link\"><a href=\"https:\/\/dockerpros.com\/it\/wiki\/container\/\" target=\"_blank\">container<\/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\/it\/wiki\/container\/\">More \u00bb<\/a><\/span><\/span><\/span><\/span><\/span> fails a <span class=\"glossaryai-tooltip glossary-term-698\"><span class=\"glossaryai-link\"><a href=\"https:\/\/dockerpros.com\/it\/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\/it\/wiki\/health-check\/\">More \u00bb<\/a><\/span><\/span><\/span><\/span><\/span>, you can configure Docker to restart it based on the designated restart policy.<\/p>\n<p>Here\u2019s how to implement a <span class=\"glossaryai-tooltip glossary-term-698\"><span class=\"glossaryai-link\"><a href=\"https:\/\/dockerpros.com\/it\/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\/it\/wiki\/health-check\/\">More \u00bb<\/a><\/span><\/span><\/span><\/span><\/span> in a <span class=\"glossaryai-tooltip glossary-term-652\"><span class=\"glossaryai-link\"><a href=\"https:\/\/dockerpros.com\/it\/wiki\/dockerfile\/\" target=\"_blank\">Dockerfile<\/a><\/span><span class=\"gai-content-hidden glossaryai-tooltip-content\"><span class=\"gai-tooltip-body\"><span class=\"glossaryai-tooltip-text\">A Dockerfile is a script containing a series of instructions to automate the creation of Docker images. It specifies the base image, application dependencies, and configuration, facilitating consistent deployment across environments.<span class=\"glossaryai-more-link\"> <a href=\"https:\/\/dockerpros.com\/it\/wiki\/dockerfile\/\">More \u00bb<\/a><\/span><\/span><\/span><\/span><\/span>:<\/p>\n<pre><code class=\"language-dockerfile\">FROM my_image\n\n<span class=\"glossaryai-tooltip glossary-term-680\"><span class=\"glossaryai-link\"><a href=\"https:\/\/dockerpros.com\/it\/wiki\/healthcheck\/\" target=\"_blank\">HEALTHCHECK<\/a><\/span><span class=\"gai-content-hidden glossaryai-tooltip-content\"><span class=\"gai-tooltip-body\"><span class=\"glossaryai-tooltip-text\">HEALTHCHECK is a Docker directive used to monitor container health by executing specified commands at defined intervals. It enhances reliability by enabling automatic restarts for failing services.<span class=\"glossaryai-more-link\"> <a href=\"https:\/\/dockerpros.com\/it\/wiki\/healthcheck\/\">More \u00bb<\/a><\/span><\/span><\/span><\/span><\/span> --interval=30s --timeout=3s --retries=3 <span class=\"glossaryai-tooltip glossary-term-670\"><span class=\"glossaryai-link\"><a href=\"https:\/\/dockerpros.com\/it\/wiki\/cmd\/\" target=\"_blank\">CMD<\/a><\/span><span class=\"gai-content-hidden glossaryai-tooltip-content\"><span class=\"gai-tooltip-body\"><span class=\"glossaryai-tooltip-text\">CMD, or Command Prompt, is a command-line interpreter in Windows operating systems. It allows users to execute commands, automate tasks, and manage system files through a text-based interface.<span class=\"glossaryai-more-link\"> <a href=\"https:\/\/dockerpros.com\/it\/wiki\/cmd\/\">More \u00bb<\/a><\/span><\/span><\/span><\/span><\/span> curl -f http:\/\/localhost\/ || exit 1<\/code><\/pre>\n<p>This <span class=\"glossaryai-tooltip glossary-term-698\"><span class=\"glossaryai-link\"><a href=\"https:\/\/dockerpros.com\/it\/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\/it\/wiki\/health-check\/\">More \u00bb<\/a><\/span><\/span><\/span><\/span><\/span> pings the application every 30 seconds. If the check fails three times in a row, Docker will mark the <span class=\"glossaryai-tooltip glossary-term-650\"><span class=\"glossaryai-link\"><a href=\"https:\/\/dockerpros.com\/it\/wiki\/container\/\" target=\"_blank\">container<\/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\/it\/wiki\/container\/\">More \u00bb<\/a><\/span><\/span><\/span><\/span><\/span> as unhealthy. If a restart policy is applied, Docker will act according to the defined rules.<\/p>\n<h3>Troubleshooting Common Issues with Restart Policies<\/h3>\n<p>When deploying applications with Docker Restart Policies, you may encounter issues that require troubleshooting:<\/p>\n<ul>\n<li>\n<p><strong>Frequent Restarts<\/strong>: If a <span class=\"glossaryai-tooltip glossary-term-650\"><span class=\"glossaryai-link\"><a href=\"https:\/\/dockerpros.com\/it\/wiki\/container\/\" target=\"_blank\">container<\/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\/it\/wiki\/container\/\">More \u00bb<\/a><\/span><\/span><\/span><\/span><\/span> is restarting too often, inspect the logs to identify the failure reason. A poorly configured application or resource constraints might be the root cause.<\/p>\n<\/li>\n<li>\n<p><strong>Policy Conflicts<\/strong>: Ensure that the chosen policy aligns with your application\u2019s lifecycle. For instance, using <code>always<\/code> for a development <span class=\"glossaryai-tooltip glossary-term-650\"><span class=\"glossaryai-link\"><a href=\"https:\/\/dockerpros.com\/it\/wiki\/container\/\" target=\"_blank\">container<\/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\/it\/wiki\/container\/\">More \u00bb<\/a><\/span><\/span><\/span><\/span><\/span> could lead to unwanted restarts during testing.<\/p>\n<\/li>\n<li>\n<p><strong>Limitations and Bugs<\/strong>: Be aware of the limitations of the Docker version you are using. Some older versions may have bugs related to restart policies. Always keep your Docker installation updated.<\/p>\n<\/li>\n<\/ul>\n<h3>Best Practices for Using Docker Restart Policies<\/h3>\n<ol>\n<li>\n<p><strong>Document Policies<\/strong>: Clearly document the restart policies you implement for each <span class=\"glossaryai-tooltip glossary-term-650\"><span class=\"glossaryai-link\"><a href=\"https:\/\/dockerpros.com\/it\/wiki\/container\/\" target=\"_blank\">container<\/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\/it\/wiki\/container\/\">More \u00bb<\/a><\/span><\/span><\/span><\/span><\/span> to ensure team members understand the expectations and behaviors.<\/p>\n<\/li>\n<li>\n<p><strong>Test Resiliency<\/strong>: Regularly test the resiliency of your applications by simulating failures to observe how your restart policies perform in practice.<\/p>\n<\/li>\n<li>\n<p><strong>Use Monitoring Tools<\/strong>: Implement monitoring solutions like Prometheus or Grafana to gain insights into <span class=\"glossaryai-tooltip glossary-term-650\"><span class=\"glossaryai-link\"><a href=\"https:\/\/dockerpros.com\/it\/wiki\/container\/\" target=\"_blank\">container<\/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\/it\/wiki\/container\/\">More \u00bb<\/a><\/span><\/span><\/span><\/span><\/span> health and performance metrics, allowing for proactive management.<\/p>\n<\/li>\n<li>\n<p><strong>Review Policy Impacts<\/strong>: Periodically assess the impact of your restart policies on system resources and adjust as necessary based on real-world usage patterns.<\/p>\n<\/li>\n<li>\n<p><strong>Combine with <span class=\"glossaryai-tooltip glossary-term-657\"><span class=\"glossaryai-link\"><a href=\"https:\/\/dockerpros.com\/it\/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\">Orchestration refers to the automated management and coordination of complex systems and services. It optimizes processes by integrating various components, ensuring efficient operation and resource utilization.<span class=\"glossaryai-more-link\"> <a href=\"https:\/\/dockerpros.com\/it\/wiki\/orchestration\/\">More \u00bb<\/a><\/span><\/span><\/span><\/span><\/span><\/strong>: If you are using <span class=\"glossaryai-tooltip glossary-term-657\"><span class=\"glossaryai-link\"><a href=\"https:\/\/dockerpros.com\/it\/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\">Orchestration refers to the automated management and coordination of complex systems and services. It optimizes processes by integrating various components, ensuring efficient operation and resource utilization.<span class=\"glossaryai-more-link\"> <a href=\"https:\/\/dockerpros.com\/it\/wiki\/orchestration\/\">More \u00bb<\/a><\/span><\/span><\/span><\/span><\/span> tools like <span class=\"glossaryai-tooltip glossary-term-656\"><span class=\"glossaryai-link\"><a href=\"https:\/\/dockerpros.com\/it\/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\/it\/wiki\/kubernetes\/\">More \u00bb<\/a><\/span><\/span><\/span><\/span><\/span>, understand how restart policies interact with deployment strategies and <span class=\"glossaryai-tooltip glossary-term-696\"><span class=\"glossaryai-link\"><a href=\"https:\/\/dockerpros.com\/it\/wiki\/scaling\/\" target=\"_blank\">scaling<\/a><\/span><span class=\"gai-content-hidden glossaryai-tooltip-content\"><span class=\"gai-tooltip-body\"><span class=\"glossaryai-tooltip-text\">Scaling refers to the process of adjusting the capacity of a system to accommodate varying loads. It can be achieved through vertical scaling, which enhances existing resources, or horizontal scaling, which adds additional resources.<span class=\"glossaryai-more-link\"> <a href=\"https:\/\/dockerpros.com\/it\/wiki\/scaling\/\">More \u00bb<\/a><\/span><\/span><\/span><\/span><\/span>.<\/p>\n<\/li>\n<\/ol>\n<h3>Conclusion<\/h3>\n<p>Docker Restart Policies are an essential feature for maintaining the availability and resilience of containerized applications. By understanding the different types of restart policies, their implementation, and best practices, developers and system administrators can ensure that their applications remain robust in the face of failure. As microservices and containerization continue to evolve, mastering these policies will become increasingly important for achieving reliable and scalable deployments. Whether you are managing a single <span class=\"glossaryai-tooltip glossary-term-650\"><span class=\"glossaryai-link\"><a href=\"https:\/\/dockerpros.com\/it\/wiki\/container\/\" target=\"_blank\">container<\/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\/it\/wiki\/container\/\">More \u00bb<\/a><\/span><\/span><\/span><\/span><\/span> or a complex microservices architecture, the effective use of Docker Restart Policies will contribute significantly to your application&#8217;s stability and performance.<\/p>","protected":false},"excerpt":{"rendered":"<p>Docker restart policies define how containers should behave when they exit or fail. Options include \u201cno,\u201d \u201calways,\u201d \u201cunless-stopped,\u201d and \u201con-failure,\u201d allowing for customizable fault tolerance and <span class=\"glossaryai-tooltip glossary-term-681\"><span class=\"glossaryai-link\"><a href=\"https:\/\/dockerpros.com\/it\/wiki\/service\/\" target=\"_blank\">servizio<\/a><\/span><span class=\"gai-content-hidden glossaryai-tooltip-content\"><span class=\"gai-tooltip-body\"><span class=\"glossaryai-tooltip-text\">Il servizio si riferisce all'atto di fornire assistenza o supporto per soddisfare esigenze o requisiti specifici. In vari ambiti, comprende il servizio clienti, il supporto tecnico e i servizi professionali, enfatizzando l'efficienza e la soddisfazione dell'utente.<span class=\"glossaryai-more-link\"> <a href=\"https:\/\/dockerpros.com\/it\/wiki\/service\/\">More \u00bb<\/a><\/span><\/span><\/span><\/span><\/span> reliability.<\/p>","protected":false},"author":1,"featured_media":1560,"parent":0,"template":"","glossary-cat":[],"class_list":["post-764","glossary","type-glossary","status-publish","has-post-thumbnail","hentry"],"yoast_head":"<!-- This site is optimized with the Yoast SEO plugin v27.0 - https:\/\/yoast.com\/product\/yoast-seo-wordpress\/ -->\n<title>Docker Restart Policies - 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\/it\/wiki\/docker-restart-policies\/\" \/>\n<meta property=\"og:locale\" content=\"it_IT\" \/>\n<meta property=\"og:type\" content=\"article\" \/>\n<meta property=\"og:title\" content=\"Docker Restart Policies - Dockerpros\" \/>\n<meta property=\"og:description\" content=\"Docker restart policies define how containers should behave when they exit or fail. Options include &quot;no,&quot; &quot;always,&quot; &quot;unless-stopped,&quot; and &quot;on-failure,&quot; allowing for customizable fault tolerance and service reliability.\" \/>\n<meta property=\"og:url\" content=\"https:\/\/dockerpros.com\/it\/wiki\/docker-restart-policies\/\" \/>\n<meta property=\"og:site_name\" content=\"Dockerpros\" \/>\n<meta property=\"article:modified_time\" content=\"2024-07-22T20:55:30+00:00\" \/>\n<meta property=\"og:image\" content=\"https:\/\/dockerpros.com\/wp-content\/uploads\/2024\/07\/docker-restart-policies_764.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=\"twitter:card\" content=\"summary_large_image\" \/>\n<meta name=\"twitter:label1\" content=\"Tempo di lettura stimato\" \/>\n\t<meta name=\"twitter:data1\" content=\"6 minuti\" \/>\n<script type=\"application\/ld+json\" class=\"yoast-schema-graph\">{\"@context\":\"https:\/\/schema.org\",\"@graph\":[{\"@type\":\"WebPage\",\"@id\":\"https:\/\/dockerpros.com\/wiki\/docker-restart-policies\/\",\"url\":\"https:\/\/dockerpros.com\/wiki\/docker-restart-policies\/\",\"name\":\"Docker Restart Policies - Dockerpros\",\"isPartOf\":{\"@id\":\"https:\/\/dockerpros.com\/#website\"},\"primaryImageOfPage\":{\"@id\":\"https:\/\/dockerpros.com\/wiki\/docker-restart-policies\/#primaryimage\"},\"image\":{\"@id\":\"https:\/\/dockerpros.com\/wiki\/docker-restart-policies\/#primaryimage\"},\"thumbnailUrl\":\"https:\/\/dockerpros.com\/wp-content\/uploads\/2024\/07\/docker-restart-policies_764.jpg\",\"datePublished\":\"2024-07-22T20:40:36+00:00\",\"dateModified\":\"2024-07-22T20:55:30+00:00\",\"breadcrumb\":{\"@id\":\"https:\/\/dockerpros.com\/wiki\/docker-restart-policies\/#breadcrumb\"},\"inLanguage\":\"it-IT\",\"potentialAction\":[{\"@type\":\"ReadAction\",\"target\":[\"https:\/\/dockerpros.com\/wiki\/docker-restart-policies\/\"]}]},{\"@type\":\"ImageObject\",\"inLanguage\":\"it-IT\",\"@id\":\"https:\/\/dockerpros.com\/wiki\/docker-restart-policies\/#primaryimage\",\"url\":\"https:\/\/dockerpros.com\/wp-content\/uploads\/2024\/07\/docker-restart-policies_764.jpg\",\"contentUrl\":\"https:\/\/dockerpros.com\/wp-content\/uploads\/2024\/07\/docker-restart-policies_764.jpg\",\"width\":800,\"height\":600,\"caption\":\"docker-restart-policies-2\"},{\"@type\":\"BreadcrumbList\",\"@id\":\"https:\/\/dockerpros.com\/wiki\/docker-restart-policies\/#breadcrumb\",\"itemListElement\":[{\"@type\":\"ListItem\",\"position\":1,\"name\":\"Home\",\"item\":\"https:\/\/dockerpros.com\/\"},{\"@type\":\"ListItem\",\"position\":2,\"name\":\"Glossary\",\"item\":\"https:\/\/dockerpros.com\/fr\/wiki\/\"},{\"@type\":\"ListItem\",\"position\":3,\"name\":\"Docker Restart Policies\"}]},{\"@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\":\"it-IT\"},{\"@type\":\"Organization\",\"@id\":\"https:\/\/dockerpros.com\/#organization\",\"name\":\"Dockerpros\",\"url\":\"https:\/\/dockerpros.com\/\",\"logo\":{\"@type\":\"ImageObject\",\"inLanguage\":\"it-IT\",\"@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\/\"}}]}<\/script>\n<!-- \/ Yoast SEO plugin. -->","yoast_head_json":{"title":"Docker Restart Policies - 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\/it\/wiki\/docker-restart-policies\/","og_locale":"it_IT","og_type":"article","og_title":"Docker Restart Policies - Dockerpros","og_description":"Docker restart policies define how containers should behave when they exit or fail. Options include \"no,\" \"always,\" \"unless-stopped,\" and \"on-failure,\" allowing for customizable fault tolerance and service reliability.","og_url":"https:\/\/dockerpros.com\/it\/wiki\/docker-restart-policies\/","og_site_name":"Dockerpros","article_modified_time":"2024-07-22T20:55:30+00:00","og_image":[{"width":800,"height":600,"url":"https:\/\/dockerpros.com\/wp-content\/uploads\/2024\/07\/docker-restart-policies_764.jpg","type":"image\/jpeg"}],"twitter_card":"summary_large_image","twitter_misc":{"Tempo di lettura stimato":"6 minuti"},"schema":{"@context":"https:\/\/schema.org","@graph":[{"@type":"WebPage","@id":"https:\/\/dockerpros.com\/wiki\/docker-restart-policies\/","url":"https:\/\/dockerpros.com\/wiki\/docker-restart-policies\/","name":"Docker Restart Policies - Dockerpros","isPartOf":{"@id":"https:\/\/dockerpros.com\/#website"},"primaryImageOfPage":{"@id":"https:\/\/dockerpros.com\/wiki\/docker-restart-policies\/#primaryimage"},"image":{"@id":"https:\/\/dockerpros.com\/wiki\/docker-restart-policies\/#primaryimage"},"thumbnailUrl":"https:\/\/dockerpros.com\/wp-content\/uploads\/2024\/07\/docker-restart-policies_764.jpg","datePublished":"2024-07-22T20:40:36+00:00","dateModified":"2024-07-22T20:55:30+00:00","breadcrumb":{"@id":"https:\/\/dockerpros.com\/wiki\/docker-restart-policies\/#breadcrumb"},"inLanguage":"it-IT","potentialAction":[{"@type":"ReadAction","target":["https:\/\/dockerpros.com\/wiki\/docker-restart-policies\/"]}]},{"@type":"ImageObject","inLanguage":"it-IT","@id":"https:\/\/dockerpros.com\/wiki\/docker-restart-policies\/#primaryimage","url":"https:\/\/dockerpros.com\/wp-content\/uploads\/2024\/07\/docker-restart-policies_764.jpg","contentUrl":"https:\/\/dockerpros.com\/wp-content\/uploads\/2024\/07\/docker-restart-policies_764.jpg","width":800,"height":600,"caption":"docker-restart-policies-2"},{"@type":"BreadcrumbList","@id":"https:\/\/dockerpros.com\/wiki\/docker-restart-policies\/#breadcrumb","itemListElement":[{"@type":"ListItem","position":1,"name":"Home","item":"https:\/\/dockerpros.com\/"},{"@type":"ListItem","position":2,"name":"Glossary","item":"https:\/\/dockerpros.com\/fr\/wiki\/"},{"@type":"ListItem","position":3,"name":"Docker Restart Policies"}]},{"@type":"WebSite","@id":"https:\/\/dockerpros.com\/#website","url":"https:\/\/dockerpros.com\/","name":"Esperti Docker","description":"DockerPros \u2013 Il tuo punto di riferimento definitivo per Docker","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":"it-IT"},{"@type":"Organization","@id":"https:\/\/dockerpros.com\/#organization","name":"Esperti Docker","url":"https:\/\/dockerpros.com\/","logo":{"@type":"ImageObject","inLanguage":"it-IT","@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\/"}}]}},"_links":{"self":[{"href":"https:\/\/dockerpros.com\/it\/wp-json\/wp\/v2\/glossary\/764","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/dockerpros.com\/it\/wp-json\/wp\/v2\/glossary"}],"about":[{"href":"https:\/\/dockerpros.com\/it\/wp-json\/wp\/v2\/types\/glossary"}],"author":[{"embeddable":true,"href":"https:\/\/dockerpros.com\/it\/wp-json\/wp\/v2\/users\/1"}],"version-history":[{"count":0,"href":"https:\/\/dockerpros.com\/it\/wp-json\/wp\/v2\/glossary\/764\/revisions"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/dockerpros.com\/it\/wp-json\/wp\/v2\/media\/1560"}],"wp:attachment":[{"href":"https:\/\/dockerpros.com\/it\/wp-json\/wp\/v2\/media?parent=764"}],"wp:term":[{"taxonomy":"glossary-cat","embeddable":true,"href":"https:\/\/dockerpros.com\/it\/wp-json\/wp\/v2\/glossary-cat?post=764"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}