What is the best practice for zero downtime deployment of a Docker service? #492
-
In the past, I used nginx + docker compose for deployment, and there would be a few seconds of service unavailability with each deployment. I'd like to ask what is the best practice for zero downtime in dokploy? Is it traefik + replica deployment? If it could be updated in the documentation like dokku, that would b better. Thanks |
Beta Was this translation helpful? Give feedback.
Replies: 2 comments 2 replies
-
Hey, We don't have docs for zero downtime yet, you can achieve this same behavior playing with Swarm Settings, I will try this week to create some example in the docs |
Beta Was this translation helpful? Give feedback.
-
I leave you with this simple to understand example, we will use a basic express app, which does 2 things https://github.com/Dokploy/swarm-test
We are going to use Nixpacks as builder and your config should similar to this If you want to test that there is no zero downtime yet, you can simply deploy the application and then create another deployment and while doing the deployment reload the page in the path /health and you will see that a bad gateway will appear. Now go to the advanced section of our application, and go to the Swarm Settings section, we are going to modify the first section of Healtchecks. We will use this configuration specifically, paste and save it {
“Test": [
“CMD”,
“curl”,
“-f”,
“http://localhost:3000/health”
],
“Interval": 30000000000,
“Timeout": 10000000000,
“StartPeriod": 30000000000,
“Retries": 3
} This configuration basically tells to Docker to do:
that would be all, now to test it just do the same as I said above deploy your application 2 times and you will see that you will never get a bad gateway while the deployment is happening. This is something basic, however you can improve it using other configurations like rollback configs, restart policy and many other things. |
Beta Was this translation helpful? Give feedback.
I leave you with this simple to understand example,
we will use a basic express app, which does 2 things
https://github.com/Dokploy/swarm-test
/health
Endpoint which is the one that will tell us if our application is healthy.We are going to use Nixpacks as builder and your config should similar to this
If you want to test that there is no zero downtime yet, you can simply deploy the application and then create another deployment and while doing the deployment reload the page in the path /health and you will see th…