'Docker: Update container with ZERO downtime
I have a discord bot running with docker and docker-compose, how can I update the image of the container without any downtime? Its very important for me, that the bot isn't offline. My docker-compose.yml:
version: '3.0'
services:
bot:
image: myimage:1.0
restart: always
So for example if I build an new image with version 2.0 instead of 1.0 I want to update the container (manually) without the program to have any downtime.
Thanks for your replies and help :)
Solution 1:[1]
This is not possibile unfortunately using docker on a single istance server.
In large scale architectures you have to rely on orchestrators (like Kubernetes) which allow you to adopt different deployment strategies. An example is the ramped deployment strategy which allow you to do a rolling update.
In that scenario, temporarly down nodes are served by the old and not yet updated release. The process will terminate when all the nodes will be upgraded.
Solution 2:[2]
Your only option is to have a reverse proxy in front of your bot service. In that case you can:
- Create a new container with the new version of the bot
- When it's running, then update the reverse proxy configuration so it forwards the traffic from the new container
- Remove the old container
This way, the reverse proxy (and not docker) is granting the no-downtime.
Anyway, if it's not a critical service I would embrace the downtime, since it's much easier to deploy the new version.
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
Solution | Source |
---|---|
Solution 1 | |
Solution 2 | victor141516 |