1. What is CPM?

CPM is a Docker-based set of containers that provide the basis of a Postgresql-as-a-Service platform. Using CPM, organizations can quickly provision Postgresql containers with a simple point-and-click web user interface.

CPM utilizes the open source Postgresql SQL database and is open source on https://github.com/crunchydata/crunchy-postgresql-manager github for anyone to use.

Professional and secure support is offered by http://www.crunchydata.com Crunchy Data Solutions.

2. Features

CPM includes several containers which allow for the following:

  • quick deployment of Postgresql containers

  • deployment of Postgresql streaming replication clusters

  • basic backup and restore functions

  • automated DBA administration tasks

  • container monitoring

  • multi-server capability

  • pg-backrest archive restore

  • pgbadger reporting

  • Postgresql metrics collection and reporting

CPM is based on the following technologies:

  • Docker 1.8

  • Docker Swarm

  • golang

  • Angular.js

  • Prometheus

  • Postgresql

CPM components include:

  • cpm-admin : REST API for administering CPM containers

  • cpm-web : Angular.js/nginx for serving web user interface

  • cpm-collect : metrics collection to Prometheus

  • cpm-task : cron scheduled administrative tasks executor

  • cpm-promdash : Prometheus Dashboard for displaying collected metrics

  • cpm-node : Postgresql database container

  • cpm-node-proxy : proxy for interfacing with non-container based Postgresql databases

  • cpm-pgpool : pgpool container which provides a postgresql-smart load balancer

  • cpm-backup-job : postgresql backup job which performs a pg_basebackup backup

  • cpm-efk : container holding elasticsearch, fluentd, and kibana, used for log aggregation

  • cpm-restore-job : restore of a pg_basebackup backup to a new database container

  • cpm-server : server agent collecting metrics for CPM servers and disk provisioning

  • cpm-backrest-restore-job : container which performs a pg-backrest restore

  • skybridge : DNS-to-Docker agent for registering DNS names for each container

3. Developer Setup

Here are the steps required to set up a CPM development environment on a clean RHEL or Centos 7.1 minimal installation.

This instruction assumes you are using a static IP address of 192.168.0.107 for your CPM server.

However, If you want to get a build of CPM running quickly, you can create a VM using Vagrant. Just create a vagrant project directory and run vagrant using the Vagrantfile that is included in the CPM git repo:

mkdir cpmproject
cp Vagrantfile .
vagrant up

The Vagrantfile specifies libvirt by default, but you can change it to use virtualbox by replacing the libvirt reference to virtualbox within the vagrantfile.

3.1. Centos/RHEL Setup

note that for RHEL 7.1, you will need to add the following repos:

subscription-manager repos --enable=rhel-7-server-extras-rpms
subscription-manager repos --enable=rhel-7-server-optional-rpms

It is always good to run a full update on the operating system before beginning the CPM install:

sudo yum -y update

To get started, install some required packages first:

sudo yum -y install git mercurial golang wget

3.2. Setup Go Project Structure

As your development user, create the development directory as follows:

mkdir -p devproject/src devproject/bin devproject/pkg
export GOPATH=~/devproject
export GOBIN=$GOPATH/bin
export PATH=$GOBIN:$PATH
export CPMROOT=$GOPATH/src/github.com/crunchydata/crunchy-postgresql-manager
Download CPM Source
cd $GOPATH
go get github.com/crunchydata/crunchy-postgresql-manager
cd $CPMROOT
Install Local Dependencies

To install the local server dependencies, there is a script, sbin/dev-dep-install.sh, that you will run to do the various package installations:

sudo $CPMROOT/sbin/dev-dep-install.sh
Download and Install godep
cd $GOPATH
go get github.com/tools/godep
Download and Restore All Dependencies
cd $CPMROOT
godep restore
  • note: this takes a minute or two to complete *

Compile CPM
make build

3.3. Configure Docker

Edit the docker configuration (/etc/sysconfig/docker) by editing the OPTIONS parameter as follows:

OPTIONS='--selinux-enabled --bip=172.17.42.1/16 --dns-search=crunchy.lab --dns=192.168.0.107 --dns=192.168.0.1 -H unix:///var/run/docker.sock --label host=192.168.0.107 --label profile=SM -H tcp://192.168.0.107:2375'

The above configuration specifies the following:

 --bip=172.17.42.1/16 - this says for Docker to use this IP range when assiging IP addresses to created containers
 --dns-search=crunchy.lab - this tells Docker to include the crunchy.lab domain inside each container as the search domain
 --dns=192.168.0.107 - this tells Docker to include the 192.168.0.107 address as a primary DNS server address in each container
 --dns=192.168.0.101 - this tells Docker to include the 192.168.0.101 address as a secondary DNS server address in each container
 -H unix://var/run/docker.sock - this tells Docker to accept connections by the docker.sock domain socket
 -H tcp://192.168.0.107:2375 - this tells Docker to accept connections at this IP address, used by Docker Swarm specifically
 --label host=192.168.0.107 - this label is assigned to this Docker server to uniquely identify it within CPM
 --label profile=SM - this label is assigned to this Docker server to categorize it for use within CPM

Start docker

sudo systemctl enable docker.service
sudo systemctl start docker.service

3.4. Build CPM Docker Images

Pull down Prometheus images
sudo docker pull prom/promdash
sudo docker pull prom/prometheus
Build Images
cd $CPMROOT
make buildimages
sudo docker images

3.5. Disable Firewalld

sudo systemctl disable firewalld.service
sudo systemctl stop firewalld.service

The document, firewall-setup.md, shows how the CPM ports can be opened up.

3.6. Configure and Start Swarm

Currently, centos 7 only offers golang 1.4.2, and Swarm 1.0.1 requires golang 1.5. So for the time being, we will build and run Swarm 1.0.0.

Download the swarm binary as follows, within a new swarm go project:

export GOPATH=~/swarmproject
export GOBIN=$GOPATH/bin
export PATH=$PATH:$GOPATH/bin
mkdir -p $GOPATH/src/github.com/docker/
cd $GOPATH/src/github.com/docker/
git clone https://github.com/docker/swarm
cd swarm
git checkout v1.0.0
go get github.com/tools/godep
$GOPATH/bin/godep go install

This will create the swarm binary located in $GOPATH/swarmproject/bin

Start swarm up by running the $CPMROOT/sbin/run-swarm.sh script, first modify the script updating the LOCALIP and SWARM_TOKEN variables.

Get a swarm token
swarm create
Run Swarm
$CPMROOT/sbin/run-swarm.sh

A swarm guide is available at:

3.7. Setup skybridge

CPM services are found using DNS by the various parts of CPM. When a Docker image is started, we need it to be registered with a DNS service and the local machine configured to resolve using that DNS server.

CPM requires a reliable IP address of the host on which it is running. When a VM is created to develop CPM upon, you would create an extra Ethernet adapter typically so that you can assign it a static IP address. In Virtualbox, this adapter would be a Host-Only adapter for example.

The docker OPTIONS configuration above will have all the containers in CPM trying to use the skybridge DNS nameserver as the primary nameserver which is required by CPM.

Your /etc/resolv.conf should look similar to this if your network configuration is set up correctly:

search crunchy.lab
nameserver 192.168.0.107
nameserver 192.168.0.1

You can make these changes to your /etc/resolv.conf permanent by adding the following settings to your ethernet adapter configuration in /etc/syconfig/network-scripts:

DNS1=192.168.0.107
DNS2=192.168.0.1
DOMAIN=crunchy.lab
PEERDNS=no

This will cause the skybridge DNS nameserver to be queried first.

Pull down skybridge as follows:

sudo docker pull crunchydata/skybridge

Start skybridge by editing the sbin/run-skybridge.sh script to specify your local IP address, then run the skybridge container:

sudo ./sbin/run-skybridge.sh

3.8. Testing skybridge and Swarm

At this point, it is a good time to test the installation of skybridge, docker, and docker swarm.

Make sure the following processes are running:

ps aux | grep docker
ps aux | grep swarm
sudo docker inspect skybridge

You should see the docker and swarm processes running as well as the skybridge docker container.

Next, create a sample container:

docker run --name=tester --hostname=tester -it crunchydata/cpm bash

In another terminal, ping the new container:

ping tester

You should see the tester.crunchy.lab name resolving and responding to the ping command. If not, then there is a configuration error. If you can ping the tester container, then proceed on in the installation.

3.9. Start cpm-efk Logging

The default logging configuration in CPM uses the cpm-efk container to aggregate logs.

Prior to starting the cpm-efk container, modify the run-cpm-efk.sh script as documented here:

Start cpm-efk as follows:

cd $CPMROOT/images/cpm-efk
sudo ./run-cpm-efk.sh

At this point, you can test the cpm-efk container by browsing to http://192.168.0.107:5601. You should see the Kibana web console.

3.10. Start CPM Server Agent

On each server that is to run CPM, you will need to start a CPM Server Agent. The server agent is run within the cpm-server container on each server host that will be configured to be used in CPM.

Each CPM server agent needs to be started with skybridge running and also have its port 10001 mapped to the local host port 10001. CPM will attempt to communicate to each host using this port.

For this example, I will name the CPM server, newserver.

So, edit the $CPMROOT/images/cpm-server/run-cpmserver.sh script, and modify the server IP address to be that of the host you are running the CPM server upon.

Then run the script which will create a running cpm-server named cpm-newserver.

sudo ./run-cpmserver.sh
ping cpm-newserver

If you have the server running, you can test it by doing a GET to it:

curl http://cpm-newserver:10001/status
curl http://192.168.0.107:10001/status

3.11. Seed the Server

A one-time initialization of the server is performed by running the $CPMROOT/sbin/dev-setup.sh script.

This script copies files from the CPM github source directories into the local system’s /var/cpm/ directory.

Modify the sbin/dev-setup.sh script by updating the source directory environment variable DEVROOT to match your local dev system.

sudo $CPMROOT/sbin/dev-setup.sh

3.12. Running CPM

Modify the $CPMROOT/run-cpm.sh script by updating the following environment variable references:

  • INSTALLDIR - the location of your build directory

  • LOCAL_IP - the IP address of your dev box

Also, edit or remove the local host port mapping that is provided in the example to meet your local requirements for accessing CPM.

You can run CPM by running the following script:

sudo ./run-cpm.sh

This script will start several Docker containers that make up CPM.

On the dev host, the following URLs are useful:

If you are running CPM on a VM (host-only) and accessing CPM from the VM host (not the guest), then you will need to edit the dashboard server configuration via the PromDash user interface and specify the prometheus server URL as http://192.168.56.103:16000.

If you are running the CPM user interface from outside the dev host (e.g. from your vbox host browser), you will need to update a couple of javascript files with the promdash URL. By default these are specified in the javascript as cpm-promdash:3000, this will not be accessible from your vbox host unless you specify the skybridge DNS server.

The js files to change are: * servers/servers.js * projects/container-logic.js

Look for occurances of cpm-promdash:3000 and change them to the static IP address and ports listed above.

3.13. Login

To start using CPM, first log into the web interface at http://cpm-web:13001

The default superuser ID is cpm and the password is cpm. Also, you will enter the Admin URL value of http://cpm-admin:13001 on the login dialog screen.

Initially you will need to first define your CPM server which is your CPM host (e.g. 192.168.0.107, newserver)

Then you will be ready to start creating PostgreSQL instances.

  • nginx selinux issues

in some cases with selinux enabled, you might see AVC errors, if so, look at this:

3.14. Godocs

To see the godocs, install godoc, and start up the godoc server, then browse to the CPM API documentation:

go get golang.org/x/tools/cmd/godoc
godoc -http=:6060

3.15. Logging

Logging of the CPM product containers is as follows: - cpm-web - logs to /var/cpm/logs on the CPM host - cpm-admin - logs to fluentd (cpm-efk) by default - cpm-collect - logs to fluentd (cpm-efk) by default - cpm-task - logs to fluentd (cpm-efk) by default - postgres containers - logs to fluentd via syslog

see Log Aggregation for more details

3.16. Port Mapping

You will likely want to map the CPM addresses to a host IP addressto allow access from outside of the Docker assigned IP addresses. To do this you will add some port mapping to the startup script, run-cpm.sh.

For example, to allow the cpm web interface you would add the following to the docker run command for the cpm web container:

-p 192.168.0.107:13001:13001

And for the cpm admin container, you would need to map port 13001 to the local 14001 port:

-p 192.168.0.107:14001:13001

Also, for the prometheus dashboard to work, you will need to map its port to the local host:

-p 192.168.0.107:3000:3000

and also map the prometheus port to the local host:

-p 192.168.0.107:9090:9090

You can add the cpm service names to your remote DNS system to resolve or to your /etc/hosts files to resolve.

You will then need to enter these IP addresses and port numbers in the cpm web login screen and browser from a remote host.

3.17. Connecting to Containers Remotely

You can connect to a container’s database from a remote server by adding a static route to the CPM servers Docker bridge range as follows

Example
ip route add 172.17.0.0/16 via 192.168.0.107 dev ens3

With this route in place, you can now access a running container’s database on a remote host. Make sure that your remote host is not running Docker on the same Docker bridge IP range.

4. Docker Configuration

Each docker container has a dynamic assigned (by docker) IP address that is within a defined range that is configured when docker starts.

To support multiple Docker servers, we configure each Docker service to use a different Docker bridge IP address range as follows:

server1.crunchy.lab - 172.42.18.0/16
server2.crunchy.lab - 172.42.19.0/16
admin.crunchy.lab   - 172.42.17.0/16

4.1. docker DNS configuration

Docker is configured on each server to reference the DNS server for each container that it starts. This is done by altering the Docker service configuration to include the following Docker command line options:

        --dns=192.168.56.103

If you want the Docker containers to resolve to the public internet, include the public internet DNS address as well:

        --dns=192.168.0.1

4.2. docker setup

modify /usr/lib/systemd/system/docker.service:

--selinux-enabled -H tcp://0.0.0.0:4243 -H unix:///var/run/docker.sock
--bip=172.1X.42.1/16 --dns=192.168.56.103 --dns=192.168.0.1
adding --dns=192.168.0.1 allows me to touch the public internet from within the containers, this is something useful for development but needs to be considered for a real situation, this will be a different IP address on your network
  • on our POC, the bip values are as follows, each server needs a different value: server1.crunchy.lab: --bip=172.18.42.1/16 server2.crunchy.lab: --bip=172.19.42.1/16 admin.crunchy.lab: --bip=172.17.42.1/16

Enable and start docker:

        systemctl enable docker.service
        systemctl start docker.service

for any users that will be creating docker images (for development), run the following command to add a user to the docker group:

        usermod -a -G docker <your-user>

4.3. docker images

Docker images are stored in Docker Hub but you can also build them from source.

Here is an example of pulling down an image from Docker Hub:

docker pull crunchydata/cpm-admin

4.4. Docker Setup

Docker on each server host is configured as follows: On the Admin server:

        vi /usr/lib/systemd/system/docker.service

        ExecStart=/usr/bin/docker -d --bip=172.17.42.1/16 --dns=192.168.56.103 --dns=192.168.0.1 --selinux-enabled -H fd://

On the server1 host:

        vi /usr/lib/systemd/system/docker.service

        ExecStart=/usr/bin/docker -d --bip=172.18.42.1/16 --dns=192.168.56.103 --dns=192.168.0.1 --selinux-enabled -H fd://

On the server2 host:

        vi /usr/lib/systemd/system/docker.service

        ExecStart=/usr/bin/docker -d --bip=172.19.42.1/16 --dns=192.168.56.103 --dns=192.168.0.1 --selinux-enabled -H fd://

4.5. Docker Configuration Explaination

Each VM will run Docker. Docker creates a dynamic Ethernet bridge it uses to assign IP addresses to its containers. Docker by default assigns IP addresses to containers in a dynamic manner, starting with the default address range of 172.17.0.0/16

To avoid IP address conflicts on each host, we override the Docker bridges IP address range for each docker server to be unique. The POC assignments are as follows:

  • server1.crunchy.lab - 172.18.42.1/16

  • server2.crunchy.lab - 172.19.42.1/16

  • admin.crunchy.lab - 172.17.42.1/16

The IP address range is overridden by editing on each server the docker startup options in /usr/lib/systemd/docker.service

Also, we need to let the admin server have the ability to connect to the docker HTTP port on both server1 and server2 to provision containers. This requires docker to be configured as follows:

        -H tcp://0.0.0.0:4243 -H unix:///var/run/docker.sock

That configuration needs to be made in the /etc/sysconfig/docker file which gets referenced by the /usr/lib/systemd/docker.service file used to start docker.

4.6. Reference

5. Firewall Configuration

This is a set of steps that can be followed to allow you to enable firewalld (on Centos7 and RHEL 7) and run CPM.

5.1. Disable Network Manager

systemctl disable NetworkManager.service
systemctl stop NetworkManager.service
I found the following bugzilla ticket which led me to believe I should turn off NetworkManager in RHEL/CentoS 7.0, I am assuming this will be fixed in 7.1 but am not sure:

5.2. Enable IP Forwarding

vi /etc/sysctl.conf
net.ipv4.ip_forward=1

5.3. Open DNS Port

firewall-cmd --permanent --zone=public --add-service=dns
firewall-cmd --reload

5.4. Open CPM Web Port

Create a file in /etc/firewalld/services named cpm.xml

<?xml version="1.0" encoding="utf-8"?>
<service>
<short>cpm</short>
<description>cpm web interface</description>
<port protocol="tcp" port="13000"/>
</service>
Set selinux permissions:
chmod 640 cpm.xml
restorecon cpm.xml

5.5. Add the CPM service

firewall-cmd --permanent --add-service=cpm
firewall-cmd --reload

5.6. Open the Postgresql Port

firewall-cmd --permanent --zone=public --add-service=postgresql
firewall-cmd --reload

5.7. Allow Masquerading

You might not want to do this if you want finer grained firewall rules! This does allow all external hosts to route to the PG containers and masquerade as the firewall hosts ip address as the source address.

firewall-cmd --permanent --zone=public --add-masquerade
firewall-cmd --reload

5.8. Allow External Host Routing

On external hosts, you need to create a static route that allows them to reach the Docker containers (e.g. 172.18.0.0/16) via the Docker host ip (e.g. 192.168.0.103) using a particular eth interface (e.g. enp2s0):

ip route add 172.18.0.0/16 via 192.168.0.103 dev enp2s0

5.9. Allow CPM DNS

To resolve the Docker container host names, assigned by CPM Skybridge, you will need to specify on your remote hosts, the CPM DNS host ip address as the primary DNS nameserver in your /etc/resolv.conf.

6. Swarm Configuration

CPM uses Docker Swarm to virtualize multiple Docker servers into a single virtual server. This is a convenient way to implement multiple host Docker which is necessary to scale out the CPM containers onto multiple Docker hosts. In this example we run the Swarm manager and agent on the same host, this is they way a developer might run CPM. In a real setup, you would have a single manager and multiple swarm agent hosts.

For this example configuration, we start the Swarm Manager on 192.168.0.103:8000

The Swarm agent is started to listen to 0.0.0.0:2375

6.1. Installation

Swarm is provided by Docker at https://github.com/docker/swarm. Use the instructions at the Swarm github page to install a binary version of Swarm into the /usr/local/bin directory of all the servers you will be using for CPM.

Swarm needs a single token to define the cluster you are creating. This is done one-time as follows, save this token value for future reference:

swarm create
7b9fb5037919f89bd52c3c4888586be3

6.2. Docker Configuration

Docker is configured on each server to listen to 0.0.0.0:2375 for API events. On Centos/RHEL this is done by adding -H tcp://0.0.0.0:2375 in the /etc/sysconfig/docker file:

export SWARM_PORT=2375
/usr/bin/docker -d --selinux-enabled -H tcp://0.0.0.0:$SWARM_PORT --label storage=ssd --label hostname=espresso.crunchy.lab --label profile=small

Notice that we assign labels to the docker daemon, these labels are used by CPM (via Swarm) to figure out the correct server to deploy containers upon. CPM requires you classify a server with a label key of profile and value of SM, MED, or LG. This label value is used to determine where a container will be placed during the provisioning process. Also, a label key of hostname is used to provide the user a way to provision a container upon a specific host. The value of the hostname key is the fully qualified host name of the server.

6.3. Startup

On each server in your cluster, Start the swarm server agent listening to the local Docker API:

export LOCAL_HOST=192.168.0.103
export SWARM_PORT=2375
swarm join --addr=$LOCAL_HOST:$SWARM_PORT token://7b9fb5037919f89bd52c3c4888586be3

On one server in your cluster, Start the swarm manager that listens to CPM requests, in this example I specify two servers that will act as the cluster nodes, this is one simple form of Swarm Discovery:

export MANAGER_HOST=192.168.0.103
export MANAGER_PORT=8000
swarm manage --host $MANAGER_HOST:$MANAGER_PORT
nodes://192.168.0.107:2375,192.168.0.106:2375

6.4. Test

To see what servers are include in the swarm:

export MANAGER_HOST=192.168.0.103
export MANAGER_PORT=8000
swarm list token://7b9fb5037919f89bd52c3c4888586be3
docker -H tcp://$MANAGER_HOST:$MANAGER_PORT info

You now run docker commands via the swarm manager ip:port to interact with swarm:

export MANAGER_HOST=192.168.0.103
export MANAGER_PORT=8000
docker -H tcp://$MANAGER_HOST:$MANAGER_PORT info
docker -H tcp://$MANAGER_HOST:$MANAGER_PORT run
docker -H tcp://$MANAGER_HOST:$MANAGER_PORT ps
docker -H tcp://$MANAGER_HOST:$MANAGER_PORT logs

7. Licenses

CPM is built on products that include the following licenses:

7.1. Docker (Apache 2.0)

  Apache License
                           Version 2.0, January 2004
                        http://www.apache.org/licenses/

   TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION

   1. Definitions.

      "License" shall mean the terms and conditions for use, reproduction,
      and distribution as defined by Sections 1 through 9 of this document.

      "Licensor" shall mean the copyright owner or entity authorized by
      the copyright owner that is granting the License.

      "Legal Entity" shall mean the union of the acting entity and all
      other entities that control, are controlled by, or are under common
      control with that entity. For the purposes of this definition,
      "control" means (i) the power, direct or indirect, to cause the
      direction or management of such entity, whether by contract or
      otherwise, or (ii) ownership of fifty percent (50%) or more of the
      outstanding shares, or (iii) beneficial ownership of such entity.

      "You" (or "Your") shall mean an individual or Legal Entity
      exercising permissions granted by this License.

      "Source" form shall mean the preferred form for making modifications,
      including but not limited to software source code, documentation
      source, and configuration files.

      "Object" form shall mean any form resulting from mechanical
      transformation or translation of a Source form, including but
      not limited to compiled object code, generated documentation,
      and conversions to other media types.

      "Work" shall mean the work of authorship, whether in Source or
      Object form, made available under the License, as indicated by a
      copyright notice that is included in or attached to the work
      (an example is provided in the Appendix below).

      "Derivative Works" shall mean any work, whether in Source or Object
      form, that is based on (or derived from) the Work and for which the
      editorial revisions, annotations, elaborations, or other modifications
      represent, as a whole, an original work of authorship. For the purposes
      of this License, Derivative Works shall not include works that remain
      separable from, or merely link (or bind by name) to the interfaces of,
      the Work and Derivative Works thereof.

      "Contribution" shall mean any work of authorship, including
      the original version of the Work and any modifications or additions
      to that Work or Derivative Works thereof, that is intentionally
      submitted to Licensor for inclusion in the Work by the copyright owner
      or by an individual or Legal Entity authorized to submit on behalf of
      the copyright owner. For the purposes of this definition, "submitted"
      means any form of electronic, verbal, or written communication sent
      to the Licensor or its representatives, including but not limited to
      communication on electronic mailing lists, source code control systems,
      and issue tracking systems that are managed by, or on behalf of, the
      Licensor for the purpose of discussing and improving the Work, but
      excluding communication that is conspicuously marked or otherwise
      designated in writing by the copyright owner as "Not a Contribution."

      "Contributor" shall mean Licensor and any individual or Legal Entity
      on behalf of whom a Contribution has been received by Licensor and
      subsequently incorporated within the Work.

   2. Grant of Copyright License. Subject to the terms and conditions of
      this License, each Contributor hereby grants to You a perpetual,
      worldwide, non-exclusive, no-charge, royalty-free, irrevocable
      copyright license to reproduce, prepare Derivative Works of,
      publicly display, publicly perform, sublicense, and distribute the
      Work and such Derivative Works in Source or Object form.

   3. Grant of Patent License. Subject to the terms and conditions of
      this License, each Contributor hereby grants to You a perpetual,
      worldwide, non-exclusive, no-charge, royalty-free, irrevocable
      (except as stated in this section) patent license to make, have made,
      use, offer to sell, sell, import, and otherwise transfer the Work,
      where such license applies only to those patent claims licensable
      by such Contributor that are necessarily infringed by their
      Contribution(s) alone or by combination of their Contribution(s)
      with the Work to which such Contribution(s) was submitted. If You
      institute patent litigation against any entity (including a
      cross-claim or counterclaim in a lawsuit) alleging that the Work
      or a Contribution incorporated within the Work constitutes direct
      or contributory patent infringement, then any patent licenses
      granted to You under this License for that Work shall terminate
      as of the date such litigation is filed.

   4. Redistribution. You may reproduce and distribute copies of the
      Work or Derivative Works thereof in any medium, with or without
      modifications, and in Source or Object form, provided that You
      meet the following conditions:

      (a) You must give any other recipients of the Work or
          Derivative Works a copy of this License; and

      (b) You must cause any modified files to carry prominent notices
          stating that You changed the files; and

      (c) You must retain, in the Source form of any Derivative Works
          that You distribute, all copyright, patent, trademark, and
          attribution notices from the Source form of the Work,
          excluding those notices that do not pertain to any part of
          the Derivative Works; and

      (d) If the Work includes a "NOTICE" text file as part of its
          distribution, then any Derivative Works that You distribute must
          include a readable copy of the attribution notices contained
          within such NOTICE file, excluding those notices that do not
          pertain to any part of the Derivative Works, in at least one
          of the following places: within a NOTICE text file distributed
          as part of the Derivative Works; within the Source form or
          documentation, if provided along with the Derivative Works; or,
          within a display generated by the Derivative Works, if and
          wherever such third-party notices normally appear. The contents
          of the NOTICE file are for informational purposes only and
          do not modify the License. You may add Your own attribution
          notices within Derivative Works that You distribute, alongside
          or as an addendum to the NOTICE text from the Work, provided
          that such additional attribution notices cannot be construed
          as modifying the License.

      You may add Your own copyright statement to Your modifications and
      may provide additional or different license terms and conditions
      for use, reproduction, or distribution of Your modifications, or
      for any such Derivative Works as a whole, provided Your use,
      reproduction, and distribution of the Work otherwise complies with
      the conditions stated in this License.

   5. Submission of Contributions. Unless You explicitly state otherwise,
      any Contribution intentionally submitted for inclusion in the Work
      by You to the Licensor shall be under the terms and conditions of
      this License, without any additional terms or conditions.
      Notwithstanding the above, nothing herein shall supersede or modify
      the terms of any separate license agreement you may have executed
      with Licensor regarding such Contributions.

   6. Trademarks. This License does not grant permission to use the trade
      names, trademarks, service marks, or product names of the Licensor,
      except as required for reasonable and customary use in describing the
      origin of the Work and reproducing the content of the NOTICE file.

   7. Disclaimer of Warranty. Unless required by applicable law or
      agreed to in writing, Licensor provides the Work (and each
      Contributor provides its Contributions) on an "AS IS" BASIS,
      WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
      implied, including, without limitation, any warranties or conditions
      of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
      PARTICULAR PURPOSE. You are solely responsible for determining the
      appropriateness of using or redistributing the Work and assume any
      risks associated with Your exercise of permissions under this License.

   8. Limitation of Liability. In no event and under no legal theory,
      whether in tort (including negligence), contract, or otherwise,
      unless required by applicable law (such as deliberate and grossly
      negligent acts) or agreed to in writing, shall any Contributor be
      liable to You for damages, including any direct, indirect, special,
      incidental, or consequential damages of any character arising as a
      result of this License or out of the use or inability to use the
      Work (including but not limited to damages for loss of goodwill,
      work stoppage, computer failure or malfunction, or any and all
      other commercial damages or losses), even if such Contributor
      has been advised of the possibility of such damages.

   9. Accepting Warranty or Additional Liability. While redistributing
      the Work or Derivative Works thereof, You may choose to offer,
      and charge a fee for, acceptance of support, warranty, indemnity,
      or other liability obligations and/or rights consistent with this
      License. However, in accepting such obligations, You may act only
      on Your own behalf and on Your sole responsibility, not on behalf
      of any other Contributor, and only if You agree to indemnify,
      defend, and hold each Contributor harmless for any liability
      incurred by, or claims asserted against, such Contributor by reason
      of your accepting any such warranty or additional liability.

   END OF TERMS AND CONDITIONS

   Copyright 2014 Docker, Inc.

   Licensed under the Apache License, Version 2.0 (the "License");
   you may not use this file except in compliance with the License.
   You may obtain a copy of the License at

       http://www.apache.org/licenses/LICENSE-2.0

   Unless required by applicable law or agreed to in writing, software
   distributed under the License is distributed on an "AS IS" BASIS,
   WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
   See the License for the specific language governing permissions and
   limitations under the License.

7.2. DockerClient

Copyright (c) 2014, go-dockerclient authors
All rights reserved.

Redistribution and use in source and binary forms, with or without
modification, are permitted provided that the following conditions are met:

  * Redistributions of source code must retain the above copyright notice,
this list of conditions and the following disclaimer.
  * Redistributions in binary form must reproduce the above copyright notice,
this list of conditions and the following disclaimer in the documentation
and/or other materials provided with the distribution.

THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE
FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.

7.3. JSON Rest API (MIT License)

Copyright (c) 2013-2014 Antoine Imbert

The MIT License

Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.

7.4. Postgres PQ Library

Copyright (c) 2011-2013, 'pq' Contributors Portions Copyright (C) 2011 Blake Mizerany

Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.

7.5. AngularJS

The MIT License

Copyright (c) 2010-2014 Google, Inc. http://angularjs.org

Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in
all copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
THE SOFTWARE.

7.6. Twitter Bootstrap

The MIT License (MIT)

Copyright (c) 2011-2014 Twitter, Inc

Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in
all copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
THE SOFTWARE.

7.7. Go Language

Copyright (c) 2012 The Go Authors. All rights reserved.

Redistribution and use in source and binary forms, with or without
modification, are permitted provided that the following conditions are
met:

   * Redistributions of source code must retain the above copyright
notice, this list of conditions and the following disclaimer.
   * Redistributions in binary form must reproduce the above
copyright notice, this list of conditions and the following disclaimer
in the documentation and/or other materials provided with the
distribution.
   * Neither the name of Google Inc. nor the names of its
contributors may be used to endorse or promote products derived from
this software without specific prior written permission.

THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
"AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.

8. Other Documentation

CPM has multiple REST APIs which are documented here: REST API Documentation