Deploying with Immutable Instances

Simplicity in system design increases a total system's margin for error and the concept of using immutable instances, is a major building block towards achieving simplicity. Docker essentially provides immutability by being able to build, configure and deploy instances, following a strict pattern (not requiring manual intervention), but a more basic approach is simply launching images.

Immutability, is to make an instance immutable, or unchangeable, so as application code changes, we launch new identical base-images with new application code. We don't make changes to existing images, as these changes could alter the 'state', making it more difficult to launch subsequent images without being sure of what the current 'state' is.

A base-image should include everything you'd expect on your instance to make it function as a server, and potentially interact with other servers in its own ecosystem, such as for logging, error report etc. For example, on this image you would have Ubuntu, and services for time, log rotation, access control, SSH keys etc. You would also have installed your web server such as NGINX, and all of the directories and config files necessary for it to run at launch time of the base image.

On top of the base-image, you would simply clone your application into the expected destination, where NGINX can serve it up properly, and you're off and running.

Going forward, you could reload any modified application code, or in a purely immutable world, you would launch a new server (base image + application code) and kill off your old instance(s).

Carson R Cole