Cassandra in a Container on OSX

Tue, Mar 8, 2016

Getting Your Laptop Setup

Let’s get Cassandra running, using containers to keep the runtime environment similar to what it would be in production.  We are focusing on OSX only and will use a few tools that are freely available to make it all work.

  1. Install Brew

  2. Install CaskRoom

  1.  Install Docker Toolbox but with brew/caskroom
  1.  Install cqlsh so you can mess with Cassandra

5. We need git and npm too, so if you don’t already have them installed:

  1. Do a global install of av and the docker plugin

Launching the Container

The workflow is optimized by av-shell and the av-docker plugin that together remember multiple pieces of context so as to minimize command line arguments needed.  I invite you to compare against the’s Build your own image instructions.

  1. Get the ‘cassandra-container’ code from github
  1. Get the domain specific shell up
  1. Make sure the virtual machine that runs docker server is running

You should see column headings but no containers.

  1. Now choose which container we will work with (this project has only one) with:

Use the arrow keys to select cassandra-1.2

  1. Now build the container

This reads the Dockerfile which has been setup to install java and cassandra.

  1. Now start the container with

This reads the Runfile with specifics to map OSX directories to the container

  1. Confirm the container is running

You should see something like this:

Optionally, you can shell into the last started container with just:

8. In a new terminal, lets login to the running container

We are using an updated cqlsh installed locally to connect with Cassandra 1.2.19 but nowadays a current version of Cassandra is 3.0 so we need to set a compatible ‘cqlversion’.  You should see something like this:


The Dockerfile must have a line that sets the user id of the ‘cassandra’ user to that of the docker server so that storage can be passed from OSX through to the container.

This only works for Cassandra 1.2.X as 2.0 introduced hardlinks to the filesystem and that doesn’t work with Virtualbox.  Hopefully more to come on that front.