Command and Control for Joyent ContainerBuddy

In earlier posts I have discussed my journey to set up Docker containers at Joyent. I have developed a set of scripts to make it easier to deploy, scale and inspect my containers. Nothing fancy here; just a set of command line menus dynamically driven based on the docker-compose.yml.

The source code is available on bitbucket.

Feel free to adapt it to your environment if you would rather work from the command line than a web interface.


This is a set of scripts to control services that use Joyent containerbuddy along with nginx and consul

  1. ContainerBuddy
  2. Consul

There are four scripts

  1. setuptriton_template.sh which configures your environment
    You will need to modify that file to put your user information and then copy it to setuptriton.sh
  2. start.sh a modified version of the start script from container buddy which launches consul and nginx
  3. start.sh which starts and individual service
  4. manage.sh which wraps all this in command line menus

You will also need docker-compose.yml. See the docker-compose and container buddy documentation for more information.
default.ctmpl is used by container buddy to configure nginx. This version is slightly different than the default version.
See blog for details.
dnsConfig.json is used in that process also.

Environment variables: The following are expected to be present

  1. ${HOME}

Your key for Joyent is expected to be found in ${HOME}/.ssh/id_rsa
You can, of course, modify setuptriton.sh to change that.

You launch the process with manage.sh

./manage.sh <prefix>

All your containers will be prepended with prefix. If you don’t provide a prefix “test” will be used.

For example:
prod_nginx_1 would be the first instance of the nginx container if you used the prefix “prod”

The menus

The main menu:

Current region: east nginx and consul up and running
1) DSR            3) tail-nginx     5) Services       7) QUIT
2) Status         4) open-consul    6) Change_Region
  1. DSR - Stop and Remove all containers in the region. Nice for development but be careful!
  2. Status - Shows a list of running containers
  3. tail-nginx - tails the access.log for nginx. Ctrl-c to quit
  4. open-consul - Opens the consul gui in a browser (works on Mac. No idea if it works elsewhere)
  5. Services - Opens a sub-menu for controlling individual services
  6. Change_Region - Switch regions
  7. Quit - exit the application

The services submenu:

1) consul        3) hexo          5) socketserver  7) ninja
2) nginx         4) notify        6) crypto        8) QUIT

The list of services defined in your docker-compose.yml
Selecting a service will open the service submenu. If you have more than one instance you will be prompted to select the instance.

The service submenu

1) Stop        3) Scale       5) DockerLogs  7) Done
2) Inspect     4) Shell       6) Remove

If the service is not running Stop will be replaced with Start

  1. Start/Stop - Starts or stops the container. When starting it first pulls the lastest image.
  2. Inspect - runs docker-inspect on the container
  3. Scales - creates more instances of the container. Currently hard code to 1,2,3,4,5. 1 makes no sense but it is really annoying if the menu prompt number differs from the instances
  4. Shell - runs docker exec -it xxx bash on the container
  5. DockerLogs - runs docker logs on the container
  6. Remove - Stops and removes the container.
  7. Done - returns to the main menu.