Image for post
Image for post

Docker in Many Ways

Orchestrating Docker Containers Solutions

I create several tutorials on orchestrating WordPress and MySQL docker containers through a variety solutions. WordPress is gestalt solution for demonstrating change automation as it is a classic multi-tier monolithic web application that is quite popular.

The Problem

I divided the problem into into two basic features and advance features.

The Basic Features

Getting started, we want to simply launch two containers and verify the solution works by pointing your web browser to localhost:8080.

Image for post
Image for post

The Advance Features

For this, we want to create a private network resource and have the containers use this, create a volume that is mounted for the database with the MySQL container, and support WORDPRESS_PORT, so that we can change the host port.

Image for post
Image for post

Requirements Documentation

Validation

Validation will be to try the solution once with the default port, and again using an alternative port. Point your web browser to the appropriate port, and try out the WordPress application.

Verification

Manual Verification of Basic Features

With the commands docker, jq, and grep, we can test to see if the containers are configured correctly.

Image for post
Image for post

Manual Verification of Advance Features

Using the same commands, we can verify advanced features:

Image for post
Image for post

Automated Verification

For verifying the solution in an automated way, we can download this script below:

inspec exec container_test.rb
echo "port: $WORDPRESS_PORT" > attributes.yml
inspec exec container_test.rb --attrs=attributes.yml

Final Solutions

Docker CLI in Shell

Docker CLI in Perl, Ruby, or Python

Docker-Compose

Ansible

Python (Docker Python SDK)

Vagrant

Terraform

Other Alternatives

I have not yet tried out these scenarios.

Curl (or Pure REST)

Ruby Language

Go Language

Chef Cookbooks

Puppet Modules

Salt Stack Formulas

Systemd

Which should I use?

The main purpose of these articles were to teach Docker and the related technology, but I am sure the question will arise, which solution should I use?

  • Continuous Integration
  • Deployed to Infrastructure: test, stage, uat, prod

Local Development

I almost always use Docker Compose as it is a great no fuss container orchestration.

Continuous Integration

For most cases, Docker Compose is also a great fit, and you can reuse the tooling from local development, making use of environment variables, such as BUILD_ENV=CI vs. BUILD_ENV=dev, to toggle options.

Infrastructure Deployments (Test, Stage, UAT, Prod)

In this scenario, the database or other persistent storage are managed as an external source. For strictly the container portion, where I am running a web application, I would use either a deployment tool for simple needs, or robust scheduler.

Conclusion

This article was to provide essentially and index into articles that I have published, and also to provide a clear set of requirements. The articles that state the problem (often the part 1) may prove useful, as they provide some hints or are further tailored to that unique tool.

Written by

Linux NinjaPants Automation Engineering Mutant — exploring DevOps, Kubernetes, CNI, IAC

Get the Medium app

A button that says 'Download on the App Store', and if clicked it will lead you to the iOS App store
A button that says 'Get it on, Google Play', and if clicked it will lead you to the Google Play store