blue/green deployments with docker-compose
Recently we had the challenge of running different versions of the same application side-by-side on the same machine.
The original composition looked like this:
The services consist of “master” and “worker” applications that communicate via DNS and port bindings. This presents a problem. If we want two sets of each application instance, then they need to have unique names:
Here you can see that they’re segregated by different networks. Green applications won’t be able to access blue applications via DNS and vice-versa. The only way to communicate with the applications are via the two different host ports that are mapped to the master instances. Internally the containers use the domain name aliases defined with external_links
, which sidesteps the problem of the suffixed service names not matching what the application expects.
Making changes is as easy as updating the file and running docker-compose up
. The file contents are diffed against the running containers, so that only the ones that have changed are created/destroyed.