Search code examples
dockerdns

Switching app versions with docker container


I'm looking to do to the following scenario:

  • Build my application with an automated tool like Jenkings for example
  • When the build/tests succeed, I want to create a new docker container with the new version of the application in it.
  • I would than have all the other applications that make use of the newly deployed app/service, use the newly created container instead of the old one. So when other containers are for example using "calculator.local:3000" I would like to have this pointing to my new container, instead of the old one
  • When everthing succeeds I want to delete/archive the old container

What would be the correct way to create such a setup, I came accross a lot of complex systems involving DNS-servers, but I'm really looking somewhat more easy to setup.


Solution

  • Similar to what you want to achieve is process called blue-green deployment. It relies on that there are always 2 versions of application running (blue and green), and one is set to active which means all production traffic is routed to it.

    Let's say blue container is currently active. Deployment is done by updating green container, and changing proxy to route traffic to green app. When done properly, you can have zero downtime. But, the hardest part is to setup this proxy, which will be dynamically updated with application container ip. This can be done using consul, consul's registrator, and consul-template.

    Here are few guides, how to setup blue green deployment: