Over a million developers have joined DZone.

Introducing Depcon: The Fastest Way to Deploy Docker to Mesos/Marathon

DZone's Guide to

Introducing Depcon: The Fastest Way to Deploy Docker to Mesos/Marathon

How to use the open source Depcon library to easily deply Docker to a Mesos or Marathon cluster.

· DevOps Zone ·
Free Resource

Read why times series is the fastest growing database category.

Depcon is the fastest way to start deploying Docker containers to a Mesos/Marathon cluster.  Here are a list of features to help you get started using Depcon in your deployment pipeline:

  • Native Binary: Written in Go with binary support for Linux, Mac OS X, Windows & BSD systems
  • Full Marathon Support: Supports 100% of the Marathon API
  • Multi formats descriptors: Accepts Marathon deployment descriptors in JSON or YAML
  • Group Support: Support for creating advanced deployment groups with nested dependencies
  • Output Format: All output and responses can be outputted in CLI Tabular, JSON or YAML formats
  • Property Substitution: Supports ${PROPERTY} substitution within the application descriptor.  For example you can inject values from the build system directly into the template which resolves and deploys
  • Scaling: Quickly scale a running Docker application to set desired instance count
  • Resources: Quickly update CPU or Memory of a running  Docker application
  • Task: Full task management
  • Async/Sync Deployments:  Depcon allows you to deploy an application and either wait for it to become healthy or simply deploy and exit allowing you to poll on your own frequency using Depcon.
  • Environment Configuration: Depcon creates and uses a configuration file which allows you to define preferred global options as well as named environments.  With named environments authentication details and endpoint info is saved allowing you to switch between environments quickly.

Kubernetes, Compose, and Amazon ECS Future Support

The goal of Depcon is to offer one tool which can be used to deploy to the common technologies.  The current roadmap aims to fully support Kubernetes, Compose & ECS environments.  This will allow you to integrate Depcon into your existing deployments and control a hybrid data center.    We also have on the roadmap the ability to use a Compose file and convert it into the appropriate descriptor type for the environment it's being deployed to whether its Mesos/Marathon, Kubernetes or Amazon ECS.

Installing Depcon

To Install Depcon Binary:

  1. Download a binary for your architecture at: https://github.com/gondor/depcon
  2. Copy the depcon binary to your system path

On Ubuntu or Debian: 

  1. Download the Debian package from https://github.com/gondor/depcon
  2. In your terminal run: sudo dpkg -i depcon-ver-arch.deb

Installing From Source:

go get -v github.com/gondor/depcon

Running Depcon For the First Time

Running Depcon for the first time will execute a CLI based wizard asking for a few preferences and allowing you to define your first environment.   Here's an example of the walk thru:

$ depcon

------------[   Generating Initital Configuration   ]----------

Root single environment [Y/n]? Y
Default output format (can be overridden via runtime flag)
1 - column
2 - json
3 - yaml
Option: 1

Environment Name (eg. test, stage, prod) : test
Marathon URL (eg. http://hostname:8080)  : http://marathon-uri:8080
Authentication Required [y/N]? N

Deploying Your First Marathon Application

Now that we have configured our first environment, let's deploy a Docker application to Marathon using Depcon.  As part of this example we'll also demonstrate the ability to substitute tokens within the application descriptor.

Let's grab one of the recipes from Marathon's site but add a ${NAME} parameter for substitution. Save this file as busybox.json

    "id": "simple-docker", 
    "container": {
      "docker": {
        "image": "busybox"
    "cmd": "echo hello from ${NAME}",
    "cpus": 0.2,
    "mem": 32.0,
    "instances": 2

YAML Support:  The above is a Marathon application descriptor in JSON format.  Depcon extends this by allowing you to define the above in YAML or JSON.   You can easily convert back and forth between formats with Depcon by using convert subcommand

Using Depcon let's deploy busybox.json to our test environment we created during the first run.  We will also substitute the ${NAME} param with the value of "Marathon"

$ depcon app create busybox.json -p NAME=Marathon --wait

INFO [depcon.deploy.wait]: Waiting for application deployment to complete for /simple-docker
INFO [depcon.deploy.wait]: Waiting for application deployment to complete for /simple-docker
INFO [depcon.deploy.wait]: Waiting for application deployment to complete for /simple-docker
INFO [depcon.deploy.wait]: Application deployment has completed for /simple-docker, elapsed time 7.58 sec(s)
WARNING [depcon.deploy.wait]: No health checks defined for '/simple-docker', skipping waiting for healthy state

ID:   /simple-docker
CPUs:     0.20
Memory:   32.00
Ports:    10000
Instances:  2
Tasks:          Staged                   : 2
                Running                  : 0
                Healthy                  : 0
                UnHealthy                : 0

Container:      Type                     : Docker
                Image                    : busybox

As you can see by specifying the --wait option, Depcon waited until the application was fully staged and then exited the loop. If health checks were defined then Depcon would wait until all checks have been run.

Below you can see in the screen capture that Marathon has the "simple-docker" application running and the ${NAME} param was changed to "Marathon". Alternatively if NAME was an environment variable the -p option could be omitted.


Removing/Destroying an Application

Removing a running application with Depcon is a single command.  Let's remove the "simple-docker" application we created above:

$ depcon app destroy simple-docker

DEPLOYMENT_ID                         VERSION
c351f8b3-cf72-43e8-aeb3-19a127120b2e  2015-11-03T21:19:40.769Z

Other Common Operations

Listing all running applications:

depcon app list

Getting an application in JSON form:

depcon app get simple-docker -o json

Rolling an application back to a previous version:

depcon app rollback myapp version

Scaling an application:

depcon app scale myapp 4

Listing all running tasks:

depcon task list

In Summary

The above is just a small portion of what can be accomplished using Depcon as your deploy tool.  With the ability to wait for applications to become healthy with output in CLI, JSON or YAML, makes it easy to integrate with Jenkins or any other deployment pipeline.

We hope to have by early 2016 full support for Kubernetes, Amazon ECS and Docker compose allowing Depcon to be a single tool to run Docker locally or against a cluster with application descriptors as your recipes.

To contribute, star or follow the active development visit the Depcon project on Github

Learn how to get 20x more performance than Elastic by moving to a Time Series database.

marathon ,docker

Opinions expressed by DZone contributors are their own.

{{ parent.title || parent.header.title}}

{{ parent.tldr }}

{{ parent.urlSource.name }}