By this point, it is assumed you have completed Module 1 and Module 2 and are familiar with basic Docker commands such as docker run
, docker ps
, docker pull
, docker rm
, and the various parameter flags (such as -v
for volume mounts) associated with some of these commands.
It should also be obvious at this point that deploying docker containers at scale by hand with docker run
commands can be very involved and, at time, too complicated with multiple lines of docker ..
commands to deploy a large environment. Luckily, docker containers are not meant to be deployed via individual commands, rather they are often deployed to a desired state using various other tools that help automate and/or orchestrate microservices backed by docker containers. Some of these accompanying tools are provided below for reference.
- Kubernetes -- Google's container orchestration and automation solution to schedule and maintain service state of docker containers.
- Mesos/Marathon -- Another Automation platform (Mesos) with an orchestration framework (Marathon) to ensure service state of docker containers.
- Rancher -- Opensource container management solution that makes it easy to deploy and manage containers in their own 'Cattle environments' and can even operate and manage other orchestration platforms like Kubernetes, Mesos/Marathon, and Docker Swarm.
- Docker Swarm -- Docker's solution to automation and orchestration of clustered resources to provide a pool of Docker hosts into a single, virtual Docker host.
- Docker Compose -- A automation tool for defining and running multi-container Docker applications. This tool is less sophisticated than the ones listed above and more simpler to use but with fewer features for larger deployments at scale.
In this module, we will be focusing on learning how to use Docker Compose to provision a self contained development environment based on a single input file that describes our desired state and configuration.
Source of description comes from Docker's documentation.
Compose is a tool for defining and running multi-container Docker applications. With Compose, you use a Compose file to configure your application’s services. Then, using a single command, you create and start all the services from your configuration.
Using Compose is basically a three-step process.
Step 1: Define your container with a Dockerfile
so it can be reproduced anywhere. Either have provide the Dockerfile as an input or have the defined container hosted in a docker registry like docker hub.
Step 2: Define the containers that make up your microservices in a docker-compose.yml
file so it can be run together with other containers in an isolated environment. The docker-compose.yml
basically consist of key
: value
pairs as per the yaml syntax describing the desired state of your services.
Step 3: Lastly, run the command docker-compose up
and Compose will start and run your entire microservice based app as per the desired state.
In this module, we are going to automate the deployment of a simple, self contained, dockerized sandbox environment to write scripts that issue NITRO commands to your NetScaler ADCs. In this case we will be issuing commands to a NetScaler CPX that will be locally provisioned on your machine to load balance simple containerized websites. However, it should be noted that this tutorial can be translated to develop and issue commands against other NetScaler ADCs as well if desired.
The desired environment will have the following topology:
Services include:
-
Webserver A which is a static containerized HTTP website
-
Webserver B which is another static containerized HTTP website
-
NetScaler CPX which will be the target NetScaler to send NITRO API calls to load balance webserver A and webserver B.
-
Cloud9 IDE which is web-based Interactive Developer Environment that allows for rapid scripting and coding through a web browser.
All the services above will be isolated in a dedicated Docker Network. Individual web interfaces that we will need direct external access to will have external ports mapped to the container for access from the underlay network (basically your host's LAN).
Reset the environment by typing in the following command in your sandbox environment:
sudo /dockerclean.sh
If you are following along on your local machine, enter the following commands to remove all docker containers, images, and docker volumes from your host:
docker kill $(docker ps -q)
docker rm -f $(docker ps -a -q)
docker rmi $(docker images -q)
docker volume rm $(docker volume ls -qf)
Navigate to and complete the following exercises within Module 3: