In my Docker guides I always use the “always” restart policy. If for one reason or another you decide to change this policy, I will explain to you how to do it quickly and easily. First of all, you need to know that there are 4 policies for restarting docker containers:
- always Always restart the container if it stops. If it is manually stopped, it is restarted only when Docker daemon restarts or the container itself is manually restarted. (See the second bullet listed in the restart policy details)
- unless-stopped Similar to always, except that when the container is stopped (manually or otherwise), it is not restarted even after Docker daemon restarts. For example, if you have “unless-stopped” restart policy when watchtower automatically updates some containers to a newer version, the containers will not start automatically after the update which means you will have to restart them manually.
- on-failure Restart the container if it exits due to an error.
- no Do not automatically restart the container. (Default).
Please Support My work by Making a Donation.
Install Portainer using my easy step by step guide. Skip this step if you already have Portainer installed. Attention: Make sure you have installed the latest Portainer version.
Open Portainer then click on the container for which you want to change the restart policy. Follow the instructions in the image below.
After you click on the container at STEP 3, scroll down on the page until you see a RESTART POLICIES text. On the Dropdown menu change the restart policy according to your needs then click the Update button. Follow the instructions in the image below.
If everything goes right, you will see this message at the top right of your screen: “Success Restart policy updated“. Follow the instructions in the image below.
Note: You can replicate the same STEPS above for every container for which you want to change the restart policy.
This post was updated on Thursday / September 8th, 2022 at 11:35 PM