February 10, 2018
What is Docker?
- a lightweight container engine
- with versioned copy-on-write file system
- and declarative build
The five-minute video below provides an excellent overview:
The contents of the container are declared in “Dockerfile” (similar to Vagrantfile, Makefile, etc.). When Dockerfile is built, it produces a “Docker image” which can be started to create a “Docker container.”
Docker is similar to Vagrant (based on VMs). Both:
- leverage declarative configuration:
- produce an image with all the files
- images can be run multiple times to create “containers”
- can allow resources like folders to mount from the host computer
But Docker is different because:
- images have layers (like VMWare)
- file system is copy-on-write to allow image layering
- containers rely on a lightweight isolated process on the host OS, instead of running their own full-blown isolated OS
You can pull images from DockerHub similar to installing packages in NPM. One notable example is Alpine OS image, which is only 5 MB in size. DockerHub has images for virtually anything, including official images for MongoDB, MySQL, and a 40MB Alpine-based Java image.
Because Docker images are layered, when you deploy (or download) a new image you only need to download layers you don’t already have. This helps to speed up deployments quite a bit.
I recommend downloading and installing it yourself on Linux or Mac because Docker isn’t well integrated into package managers. The Brew package didn’t work for me at all.
What is Docker Compose?
Docker Compose is a declarative YAML file which usually describes a set of Docker images working together. For testing purposes, it is convenient to use one file to define and run images for a Web app and a database that work together in a test environment.
The 12-minute video below provides a nice overview:
What is Kubernetes?
Kubernetes (k8s) is software that manages clusters of Docker containers. It can declare dependencies between Docker images, but uses a different format that is incompatible with Docker Compose.
My favorite resources:
Like a Swiss-army knife, Kubernetes has a lot of features. The one we are most interested in is health-monitored rollout (“blue-green” deployment). This allows you to define “health check” on your system (ping APIs for us). K8s will attempt to roll out a new version and, if it starts up well, it will replace the old version. This allows you to achieve de-facto zero downtime.
How do we use Docker at TestRigor?
Docker allows us to establish declarative, versioned images for deployment.
Docker Compose lets us test locally without the need to build, checkout and start all dependencies. We can also conduct PR-initiated integration/smoke testing.
Kubernetes clusters are used for several projects to achieve zero-downtime deployment.