Zero-Downtime Deployments with Docker Swarm and Portainer - Part 1/2
Zero-downtime deployments with Docker Swarm and Portainer Part 1/2 What are Zero-downtime …

In Part 1, we explored the differences between rolling updates and zero-downtime deployments. We then prepared our stack to perform a zero-downtime deployment.
In this part, we will look at how we can update our application via Portainer. We will trigger an update automatically via GitHub, so we don’t have to do anything in Portainer.
At this point, I assume there is a running Portainer instance and the project from Part 1 is either on GitHub (used in this example) or another version control system.
If the project is in a private repository, we need to create a GitHub Personal Access Token. How to do this is described below:
Since our project is in a private repository, we need to create a Personal Access Token. We can then store this in Portainer so that Portainer can access our repository.
On GitHub, this is quite simple, and we only need to follow these steps:
This can also be read in the GitHub documentation.
Now we create a new stack in Portainer and link it with our GitHub repository. We set it up so that Portainer automatically triggers an update as soon as we push a new version to GitHub.
First, we create a new stack in Portainer:

Authentication so that Portainer can access our repositoryAt this point, we have linked our project on GitHub with Portainer. Now we need to set up Portainer to automatically trigger an update as soon as we push a new version to GitHub.

Enable the option GitOps updates
Here we have several options for how Portainer can fetch the updates. By default, Polling is used, which means Portainer checks for updates at regular intervals. We can also use Webhooks, where Portainer is notified by GitHub as soon as an update is available. To do this, we would need to create a webhook in GitHub, but that would go beyond the scope here. Therefore, we use Polling.
We can also see that Re-pull image and Force redeployment are premium features available only in the business version of Portainer.
Re-pull image means that Portainer downloads the image again as soon as an update is available.
Force redeployment means that Portainer restarts the application as soon as an update is available.
Finally, click the Deploy the stack button, and Portainer will deploy the project from the repository.
I recommend checking out the documentation on Portainer. From this point, we can make changes to our stack on GitHub, and Portainer will automatically deploy them. The application will not go offline, achieving a zero-downtime deployment.
At this point, I won’t explicitly show the update process via GitHub and Portainer, as it would be too extensive. I recommend you take a look at it yourself. It’s really very simple and intuitive.
Zero-downtime deployments with Docker Swarm and Portainer Part 1/2 What are Zero-downtime …
Five Key Features of Portainer 1. Docker Environments 2. Access Control 3. CI/CD Capabilities 4. …
Why This Post? What is Portainer? Practical Section Deploying Portainer Setting Up Portainer …