Need help with cassandra?
Click the “chat” button below for chat support from the developer who created it, or find similar developers for support.

About the developer

200 Stars 95 Forks MIT License 78 Commits 8 Opened issues


A Docker Cassandra container

Services available


Need anything else?

Contributors list

# 123,569
Apache ...
47 commits
# 388,989
Apache ...
3 commits
# 62,725
Apache ...
2 commits
# 405,175
Apache ...
2 commits
# 474,331
Apache ...
1 commit
# 36,448
Apache ...
1 commit
# 318,718
Apache ...
1 commit
# 191,561
Apache ...
1 commit

Cassandra on Docker

This is a collection of images and scripts to help you run Cassandra in Docker containers. These images are great to provision ephemeral Cassandra topologies for testing and development purpose.

  • Currently supported:
    • A single Cassandra node
    • A client container to run tools such as cqlsh, nodetool, etc.
    • A multi-node cluster - running on a single Docker host
    • Monitored cluster using OpsCenter

If you'd like to help, please get in touch with me, and/or send me pull requests.


  • A recent version of Docker - See
  • Verify that the docker command works. Try running 'docker ps' for example.
  • Build the cassandra and opscenter images (optional)


The last step is optional because Docker will automatically pull the images from if you don't already have them. The build process needs an Internet connection, but it is executed only once and then cached on Docker. If you modify the scripts, this is also how you can re-build the images with your changes.

Single Cassandra node

Here's how to start a Cassandra cluster with a single node, and run some CQL on it. These instructions use the docker command directly to demonstrate what's happening behind the scenes.

  1. Launch a container running Cassandra called cassone:

    docker run --detach --name cassone poklet/cassandra
  2. Connect to it using cqlsh

    docker run -it --rm --net container:cassone poklet/cassandra cqlsh

    You should see something like:

    [cqlsh 5.0.1 | Cassandra 2.2.0 | CQL spec 3.3.0 | Native protocol v4]
    Use HELP for help.
    cqlsh> quit

    If not, then try it again in a few seconds - cassandra might still be starting up.

  3. Lets try some CQL

    Paste the following into your cqlsh prompt to create a test keyspace, and a test table:

    {'class': 'SimpleStrategy', 'replication_factor': 1};

    USE test_keyspace;

    CREATE TABLE test_table ( id text, test_value text, PRIMARY KEY (id) );

    INSERT INTO test_table (id, test_value) VALUES ('1', 'one'); INSERT INTO test_table (id, test_value) VALUES ('2', 'two'); INSERT INTO test_table (id, test_value) VALUES ('3', 'three');

    SELECT * FROM test_table;

    If that worked, you should see:

     id | test_value
      3 |      three
      2 |        two
      1 |        one

    (3 rows)

3-node Cassandra cluster

  1. Launch three containers (one seed plus two more)

    docker run -d --name cass1 poklet/cassandra start
    docker run -d --name cass2 --link cass1:seed poklet/cassandra start seed
    docker run -d --name cass3 --link cass1:seed poklet/cassandra start seed

    Note: The poklet/cassandra docker image contains a shell script called

    that takes an optional seed host. We use
    --link cass1:seed
    to name the cass1 host as our seed host.
  2. Run

    nodetool status
    on cass1 to check the cluster status:
    docker run -it --rm --net container:cass1 poklet/cassandra nodetool status
  3. Create some data on the first container:


    docker run -it --rm --net container:cass1 poklet/cassandra cqlsh

    Paste this in:

    create keyspace demo with replication = {'class':'SimpleStrategy', 'replication_factor':2};
    use demo;
    create table names ( id int primary key, name text );
    insert into names (id,name) values (1, 'gibberish');
  4. Connect to the second container, and check if it can see your data:

    Start up

    (on cass2 this time):
    docker run -it --rm --net container:cass2 poklet/cassandra cqlsh

    Paste in:

    select * from demo.names;

    You should see:

    cqlsh> select * from demo.names;

    id | name ----+----------- 1 | gibberish

    (1 rows)

10-node Cassandra cluster (scripted!)

  1. Right, lets dive right in with some shell scripts in the scripts directory to help us:

    ./scripts/ 10
  2. That will start 10 nodes. Lets see what they're called:

 cass6 cass4 cass5 cass10 cass9 cass7 cass8 cass2 cass3 cass1

  3. Same, but with the nodetool:

    ./scripts/ cass1 status

    Datacenter: datacenter1

    Status=Up/Down |/ State=Normal/Leaving/Joining/Moving -- Address Load Tokens Owns (effective) Host ID Rack UN 74.19 KB 256 21.4% dfd44ca5-bf73-4487-bcb2-db882d0a9231 rack1 UN 74.21 KB 256 19.6% f479a4e6-55ac-4533-8ce5-d137a93f2cc4 rack1 UN 74.34 KB 256 20.4% 0bb389a0-f111-459c-9620-0faccc75cbc0 rack1 UN 74.19 KB 256 20.1% 2eb4a4dd-2bbc-46a3-9f64-4e761509307d rack1 UN 74.14 KB 256 20.2% a2547289-0c6a-458f-b982-823711c5293e rack1 UN 74.19 KB 256 20.3% 3667cc1a-1f63-4cd1-bebc-841f428a0f4d rack1 UN 74.24 KB 256 20.3% 2b48c8ac-ad68-48a0-9c41-c8f2fb7f38e6 rack1 UN 67.7 KB 256 19.2% e361f6d8-28ef-4cf8-baa1-88c2d1fec094 rack1 UN 74.15 KB 256 19.6% 230f13b1-a27b-44e8-9b51-5ebdb1c4cb13 rack1 UN 74.18 KB 256 18.8% 6c90cbaa-e5b3-41de-a160-3ecaf59b8856 rack1

  4. When you're tired of your cluster, nuke it with:

    ./scripts/ 10

Set snitch and node location

The snitch type and node location information can be configured with environment variables. The datacenter and rack configuration is only valid if using the GossipingPropertyFileSnitch type snitch. For example:

    docker run -d --name cass1 -e SNITCH=GossipingPropertyFileSnitch -e DC=SFO -e RACK=RAC3 poklet/cassandra

This will set the snitch type and set the datacenter to SFO and the rack to RAC3

Auto-detect seeds

Any containers linked in the run command will also be added to the seed list. The 3-node cluster example above may also be written as:

    docker run -d --name cass1 poklet/cassandra
    docker run -d --name cass2 --link cass1:cass1 poklet/cassandra
    docker run -d --name cass3 --link cass1:cass1 poklet/cassandra
    # and so on...

Specifying clustering parameters

When starting a container, you can pass the SEEDS, LISTEN_ADDRESS environment variables to override the defaults:

docker run -e SEEDS=a,b,c... -e LISTEN_ADDRESS= poklet/cassandra

Note that listenaddress will also be used for broadcastaddress

Cassandra cluster + OpsCenter monitoring

  1. Start a Cassandra cluster with 3 nodes:

    ./scripts/ 3
  2. Start the OpsCenter container:

    docker run -d --name opscenter poklet/opscenter

    You can also add the

    -p 8888:8888
    option to bind container's 8888 port to host's 8888 port
  3. Connect and configure OpsCenter:

- Open a browser and connect to []( - replace the host by the result returned by `./scripts/ opscenter`.
- Click on the "Use Existing Cluster" button and put at least the IP of one node in the cluster in the host text box. The result of `./scripts/ cass1` is a good candidate. Click "Save Cluster" button. OpsCenter start gathering data from the cluster but you do not get full-set metrics yet.
- You should see a "0 of 3 agents connected" message on the top of the GUI. Click the "Fix" link aside.
- In the popup, click "Enter Credentials" link and fill form with username `opscenter` and password `opscenter`. Click "Done".
- Click "Install on all nodes" and then "Accept Fingerprints". OpsCenter installs agent on cluster'snodes remotly.
- Once done, you should see the "All agents connected" message.

We use cookies. If you continue to browse the site, you agree to the use of cookies. For more information on our use of cookies please see our Privacy Policy.