Public | Automated Build

Last pushed: 2 years ago
Short Description
Short description is empty for this repo.
Full Description


Cassandra in docker.

Apache cassandra is an open source database management system designed to handle huge aounts of data in a highly available (no single point of failure), distributed way.

Get the docker image

You can either build it yourself, or pull it from the Docker Registry.

Build the image

docker build [--rm] -t docxs/cassandra .

Get it from Docker Registry

docker pull docxs/cassandra

Running the container

Environment variables

Once the image is on your system, you can run it in different configurations or for different purposes (see below). There's a couple of environment variables you can provide during runtime, to customize the configuration. These are:


Variable for controlling which IP address cassandra is listening on for incoming connections (listen_address in cassandra.yaml). The default value is automatically set to the ip address of the docker instance as it starts, and should work most of the time.


Variable for controlling the IP address Cassandra is advertising to other nodes (sets broadcast_address and broadcast_rpc_address in cassandra.yaml). By default, it is set to $CASSANDRA_LISTEN_ADDRESS. It can never be assigned the wildcard address (


Variable that should contain a comma separated list of the IP addresses used by gossip for bootstrapping new nodes joining a cluster (seeds of seed_provider in cassandra.yaml). It adds the $CASSANDRA_BROADCAST_ADDRESS to the list, so the instance will talk to itself as well.


Variable for setting the cluster name (cluster_name in cassandra.yaml), which must be the same for all nodes in the cluster. Defaults to MyCluster.


Variable setting the number of tokens for this instance (num_tokens in cassandra.yaml). Defaults to 256.


Variable setting the datacenter name of this node (dc in Defaults to DC1.


Variable setting the datacenter name of this node (rack in Defaults to RAC1.


Variable setting the snitch implementation this node will use (endpoint_snitch in cassandra.yaml). Defaults to SimpleSnitch.


Defaults to 1024M


Defaults to 256M

All data is saved in the /data folder of the container. If you don't want the data to be ephemeral, you can map the folder to one of the docker host system, or to a docker data container.


  • -cassandra: runs cassandra-server (default)
  • -cqlsh: runs cqlsh (with arguments)
  • -nodetool: runs nodetool (with arguments)
  • -bash: run the container with a shell session


Single Cassandra server node

Some examples:

  1. Ephemeral data in the container, and ports not mapped to the host system

     docker run -d [--name <name>] \

    ... where `<name> is the name you want to assign to your container.

  2. Persistent data on the host system, and use the hosts net stack for connection:

     docker run -d [--name <name>] \
                -v <data_folder>:/data \
                --net=host \

Multiple node cassandra cluster

There are 2 cluster scenarios

Run the first container that will act as the seed, and get the seed's ip address:

docker run -d [--name <name>] \

Then run the nth node as follows:

docker run -d [--name <name_i>] \
           -e "CASSANDRA_SEEDS=<seed_ip>"

Connect to cassandra

  1. Connect to Cassandra using cqlsh from the docker image

    You can connect to Cassandra directly by providing the ip address:

     docker run -it --rm
                <user>/cassandra -cqlsh <ip>

    ... or you can use docker linking to make the Cassandra instance available to your cqlsh application container:

     docker run -it --rm
                --link <name>:<link-name>
                <user>/cassandra -cqlsh <link-name>

    ... where <link-name> is the freely to choose hostname of the Cassandra instance within the cqlsh application container, and <name> is the name of the Cassandra instance

  2. Connect to Cassandra from any other application

    If the application is not run from within a docker container, you can connect to the Cassandra instance if you properly map the ports to the host system. If the application is run from within a docker image on the same host, you can follow the pattern given above for cqlsh. Example:

     docker run --name app
                --link <name>:<link-name>
                -d <app-using-cassandra>


Licensed under the MIT License. See the LICENSE file for details.

Feedback, bug-reports, requests, ...

Are welcome!

Docker Pull Command
Source Repository