Public | Automated Build

Last pushed: 2 years ago
Short Description
Follow installation instructions at
Full Description


This repo provides Docker containers to run:

  • Spark master and worker(s) for running Spark in standalone mode on dedicated hosts
  • Mesos-enhanced containers for Mesos-mastered Spark jobs
  • IPython web interface for interacting with Spark or Mesos master via PySpark

Please see the accompanying blog posts for the technical details and motivation behind this project:

  • <a href="" target="_blank">Using Docker to Build an IPython-driven Spark Deployment</a>
  • <a href="" target="_blank">Triplewide Trailer, Part 1: Looking to Hitch IPython, Spark, and Mesos to Docker</a>


Docker containers provide a portable and repeatable method for deploying the cluster:

<p align="center">
<img src="architecture/" alt="hadoop-docker-client connections">

CDH5 Tools and Libraries

<td><a href="" target="_blank">HDFS</a></td>
<td><a href="" target="_blank">Hbase</a></td>
<td><a href="" target="_blank">Hive</a></td>
<td><a href="" target="_blank">Oozie</a></td>
<td><a href="" target="_blank">Pig</a></td>
<td><a href="" target="_blank">Hue</a></td>

Python Packages and Modules

<td><a href="" target="_blank">Pattern</a></td>
<td><a href="" target="_blank">NLTK</a></td>
<td><a href="" target="_blank">Pandas</a></td>
<td><a href="" target="_blank">NumPy</a></td>
<td><a href="" target="_blank">SciPy</a></td>
<td><a href="" target="_blank">SymPy</a></td>
<td><a href="" target="_blank">Seaborn</a></td>
<td><a href="" target="_blank">Cython</a></td>
<td><a href="" target="_blank">Numba</a></td>
<td><a href="" target="_blank">Biopython</a></td>
<td><a href="" target="_blank">Rmagic</a></td>
<td><a href="" target="_blank">0MQ</a></td>
<td><a href="" target="_blank">Matplotlib</a></td>
<td><a href="" target="_blank">Scikit-Learn</a></td>
<td><a href="" target="_blank">Statsmodels</a></td>
<td><a href="" target="_blank">Beautiful Soup</a></td>
<td><a href="" target="_blank">NetworkX</a></td>
<td><a href="" target="_blank">LLVM</a></td>
<td><a href="" target="_blank">Bokeh</a></td>
<td><a href="" target="_blank">Vincent</a></td>
<td><a href="" target="_blank">MDP</a></td>


Option 1. Mesos-mastered Spark Jobs

  1. <strong>Install Mesos with Docker Containerizer and Docker Images</strong>: Install a Mesos cluster configured to use the Docker containerizer, which enables the Mesos slaves to execute Spark tasks within a Docker container.

    A. <strong>End-to-end Installation</strong>: The script mesos/ uses the Python library Fabric to install and configure a cluster according to How To Configure a Production-Ready Mesosphere Cluster on Ubuntu 14.04. After installation, it also pulls the Docker images that will execute Spark tasks. To use:

    • Update IP Addresses of Mesos nodes in mesos/ Find instances to change with:

      <pre><code>grep 'ip-address' mesos/</code></pre>

    • Install/configure the cluster:
      Optional: ./ if you prefer instead to build the docker images from scratch (rather than the script pulling from Docker Hub)

      B. <strong>Manual Installation</strong>: Follow the general steps in mesos/ to manually install:

    • Install mesosphere on masters

    • Install mesos on slaves
    • Configure zookeeper on all nodes
    • Configure and start masters
    • Configure and start slaves
    • Load docker images:

      <pre><code>docker pull lab41/spark-mesos-dockerworker-ipython
      docker pull lab41/spark-mesos-mesosworker-ipython</code></pre>

  1. <strong>Run the client container on a client host</strong> (replace 'username-for-sparkjobs' and 'mesos-master-fqdn' below): <pre><code>./ username-for-sparkjobs mesos://mesos-master-fqdn:5050</code></pre>
    *Note: the client container will create username-for-sparkjobs when started, providing the ability to submit Spark jobs as a specific user and/or deploy different IPython servers for different users.

Option 2. Spark Standalone Mode

Installation and Deployment - Build each Docker image and run each on separate dedicated hosts

<div><strong>Tip</strong>: Build a common/shared host image with all necessary configurations and pre-built containers, which you can then use to deploy each node. When starting each node, you can pass the container run scripts as <a href="">User data</a> to initialize that container at boot time</div>

  1. <strong>Prerequisites</strong>

    • Deploy Hadoop/HDFS cluster. Spark uses a cluster to distrubute analysis of data pulled from multiple sources, including the Hadoop Distrubuted File System (HDFS). The ephemeral nature of Docker containers make them ill-suited for persisting long-term data in a cluster. Instead of attempting to store data within the Docker containers' HDFS nodes or mounting host volumes, it is recommended you point this cluster at an external Hadoop deployment. Cloudera provides complete resources for installing and configuring its distribution (CDH) of Hadoop. This repo has been tested using CDH5.
  2. <strong>Build and configure hosts</strong>

    1. Install <a href="" target="_blank">Docker v1.5+</a>, <a href="" target="_blank">jq JSON processor</a>, and <a href="" target="_blank">iptables</a>. For example, on an Ubuntu host:


    2. Update the Hadoop configuration files in runtime/cdh5/<hadoop|hive>/<multiple-files> with the correct hostnames for your Hadoop cluster. Use grep FIXME -R . to find hostnames to change.
    3. Generate new SSH keypair (dockerfiles/base/lab41/spark-base/config/ssh/id_rsa and dockerfiles/base/lab41/spark-base/config/ssh/, adding the public key to dockerfiles/base/lab41/spark-base/config/ssh/authorized_keys.
    4. (optional) Update SPARK_WORKER_CONFIG environment variable for Spark-specific options such as executor cores. Update the variable via a shell export command or by updating dockerfiles/standalone/lab41/spark-client-ipython/config/service/ipython/run.
    5. (optional) Comment out any unwanted Python packages in the base Dockerfile image dockerfiles/base/lab41/python-datatools/Dockerfile.
  3. <strong>Get Docker images</strong>:

    <div>Option A: If you prefer to pull from Docker Hub:
    <pre><code>docker pull lab41/spark-master
    docker pull lab41/spark-worker
    docker pull lab41/spark-client-ipython</code></pre>
    <div>Option B: If you prefer to build from scratch yourself:
    <div>If you are creating common/shared host images, this would be the point to snapshot the host image for replication.</div>

  4. <strong>Deploy cluster nodes</strong>
    <div>Ensure each host has a Fully-Qualified-Domain-Name (i.e.;; for the Spark nodes to properly associate</div>

    1. <strong>Run the master container on the master host</strong>: <pre><code>./</code></pre>
    2. <strong>Run worker container(s) on worker host(s)</strong> (replace 'spark-master-fqdn' below): <pre><code>./ spark://spark-master-fqdn:7077</code></pre>
    3. <strong>Run the client container on the client host</strong> (replace 'spark-master-fqdn' below): <pre><code>./ spark://spark-master-fqdn:7077</code></pre>
Docker Pull Command
Source Repository