Introducing our new CEO Don Johnson - Read More

bitnami/cassandra

Verified Publisher

By VMware

Updated 2 days ago

Bitnami container image for Cassandra

Image
Data Science
Databases & Storage
Internet of Things
52

50M+

Bitnami package for Apache Cassandra

What is Apache Cassandra?

Apache Cassandra is an open source distributed database management system designed to handle large amounts of data across many servers, providing high availability with no single point of failure.

Overview of Apache Cassandra Trademarks: This software listing is packaged by Bitnami. The respective trademarks mentioned in the offering are owned by the respective companies, and use of them does not imply any affiliation or endorsement.

TL;DR

docker run --name cassandra bitnami/cassandra:latest

You can find the default credentials and available configuration options in the Environment Variables section.

Why use Bitnami Images?

  • Bitnami closely tracks upstream source changes and promptly publishes new versions of this image using our automated systems.
  • With Bitnami images the latest bug fixes and features are available as soon as possible.
  • Bitnami containers, virtual machines and cloud images use the same components and configuration approach - making it easy to switch between formats based on your project needs.
  • All our images are based on minideb -a minimalist Debian based container image that gives you a small base container image and the familiarity of a leading Linux distribution- or scratch -an explicitly empty image-.
  • All Bitnami images available in Docker Hub are signed with Notation. Check this post to know how to verify the integrity of the images.
  • Bitnami container images are released on a regular basis with the latest distribution packages available.

Looking to use Apache Cassandra in production? Try VMware Tanzu Application Catalog, the commercial edition of the Bitnami catalog.

Why use a non-root container?

Non-root container images add an extra layer of security and are generally recommended for production environments. However, because they run as a non-root user, privileged tasks are typically off-limits. Learn more about non-root containers in our docs.

How to deploy Apache Cassandra in Kubernetes?

Deploying Bitnami applications as Helm Charts is the easiest way to get started with our applications on Kubernetes. Read more about the installation in the Bitnami Apache Cassandra Chart GitHub repository.

Bitnami containers can be used with Kubeapps for deployment and management of Helm Charts in clusters.

Only latest stable branch maintained in the free Bitnami catalog

Starting December 10th 2024, only the latest stable branch of any container will receive updates in the free Bitnami catalog. To access up-to-date releases for all upstream-supported branches, consider upgrading to Bitnami Premium. Previous versions already released will not be deleted. They are still available to pull from DockerHub.

Please check the Bitnami Premium page in our partner Arrow Electronics for more information.

Supported tags and respective Dockerfile links

Learn more about the Bitnami tagging policy and the difference between rolling tags and immutable tags in our documentation page.

You can see the equivalence between the different tags by taking a look at the tags-info.yaml file present in the branch folder, i.e bitnami/ASSET/BRANCH/DISTRO/tags-info.yaml.

Subscribe to project updates by watching the bitnami/containers GitHub repo.

Get this image

The recommended way to get the Bitnami Apache Cassandra Docker Image is to pull the prebuilt image from the Docker Hub Registry.

docker pull bitnami/cassandra:latest

To use a specific version, you can pull a versioned tag. You can view the list of available versions in the Docker Hub Registry.

docker pull bitnami/cassandra:[TAG]

If you wish, you can also build the image yourself by cloning the repository, changing to the directory containing the Dockerfile and executing the docker build command. Remember to replace the APP, VERSION and OPERATING-SYSTEM path placeholders in the example command below with the correct values.

git clone https://github.com/bitnami/containers.git
cd bitnami/APP/VERSION/OPERATING-SYSTEM
docker build -t bitnami/APP:latest .

Persisting your application

If you remove the container all your data and configurations will be lost, and the next time you run the image the database will be reinitialized. To avoid this loss of data, you should mount a volume that will persist even after the container is removed.

For persistence you should mount a directory at the /bitnami path. If the mounted directory is empty, it will be initialized on the first run.

docker run \
    -v /path/to/cassandra-persistence:/bitnami \
    bitnami/cassandra:latest

or using Docker Compose:

cassandra:
  image: bitnami/cassandra:latest
  volumes:
    - /path/to/cassandra-persistence:/bitnami

NOTE: As this is a non-root container, the mounted files and directories must have the proper permissions for the UID 1001.

Connecting to other containers

Using Docker container networking, an Apache Cassandra server running inside a container can easily be accessed by your application containers.

Containers attached to the same network can communicate with each other using the container name as the hostname.

Using the Command Line

In this example, we will create an Apache Cassandra client instance that will connect to the server instance that is running on the same docker network as the client.

Step 1: Create a network

docker network create app-tier --driver bridge

Step 2: Launch the Apache Cassandra server instance

Use the --network app-tier argument to the docker run command to attach the Apache Cassandra container to the app-tier network.

docker run -d --name cassandra-server \
    --network app-tier \
    bitnami/cassandra:latest

Step 3: Launch your Apache Cassandra client instance

Finally we create a new container instance to launch the Apache Cassandra client and connect to the server created in the previous step:

docker run -it --rm \
    --network app-tier \
    bitnami/cassandra:latest cqlsh --username cassandra --password cassandra cassandra-server
Using a Docker Compose file

When not specified, Docker Compose automatically sets up a new network and attaches all deployed services to that network. However, we will explicitly define a new bridge network named app-tier. In this example we assume that you want to connect to the Apache Cassandra server from your own custom application image which is identified in the following snippet by the service name myapp.

version: '2'

networks:
  app-tier:
    driver: bridge

services:
  cassandra:
    image: 'bitnami/cassandra:latest'
    networks:
      - app-tier
  myapp:
    image: 'YOUR_APPLICATION_IMAGE'
    networks:
      - app-tier

IMPORTANT:

  1. Please update the YOUR_APPLICATION_IMAGE_ placeholder in the above snippet with your application image
  2. In your application container, use the hostname cassandra to connect to the Apache Cassandra server

Launch the containers using:

docker-compose up -d

Configuration

Environment variables

Customizable environment variables

NameDescriptionDefault Value
CASSANDRA_CLIENT_ENCRYPTIONEnable client encryptionfalse
CASSANDRA_CLUSTER_NAMECassandra cluster nameMy Cluster
CASSANDRA_DATACENTERCassandra datacenter namedc1
CASSANDRA_ENABLE_REMOTE_CONNECTIONSEnable connection from remote locationstrue
CASSANDRA_ENABLE_RPCEnable RPC endpoint in Cassandrafalse
CASSANDRA_ENABLE_USER_DEFINED_FUNCTIONSEnable user defined functionsfalse
CASSANDRA_ENABLE_SCRIPTED_USER_DEFINED_FUNCTIONSEnable scripted user defined functionsfalse
CASSANDRA_ENDPOINT_SNITCHName of the cluster endpoint snitchSimpleSnitch
CASSANDRA_HOSTCassandra host namenil
CASSANDRA_INTERNODE_ENCRYPTIONInternode encryption typenone
CASSANDRA_NUM_TOKENSNumber of tokens in cluster connection256
CASSANDRA_PASSWORD_SEEDERSet node as password seeder in the clusterno
CASSANDRA_SEEDSList of cluster seeds$DB_HOST
CASSANDRA_PEERSList of cluster peers$DB_SEEDS
CASSANDRA_NODESList of cluster nodes (seeders and non seeders)nil
CASSANDRA_RACKCassandra rack namerack1
CASSANDRA_BROADCAST_ADDRESSNode broadcast addressnil
CASSANDRA_AUTOMATIC_SSTABLE_UPGRADEAutomatically upgrade sstables after upgradefalse
CASSANDRA_STARTUP_CQLStartup CQL commands to run at bootnil
CASSANDRA_IGNORE_INITDB_SCRIPTSIgnore the execution of init scriptsno
CASSANDRA_CQL_PORT_NUMBERCQL port9042
CASSANDRA_JMX_PORT_NUMBERJMX port7199
CASSANDRA_TRANSPORT_PORT_NUMBERTransport port7000
CASSANDRA_CQL_MAX_RETRIESMaximum retries for CQL startup operations20
CASSANDRA_CQL_SLEEP_TIMESleep time for CQL startup operations5
CASSANDRA_INIT_MAX_RETRIESMaximum retries for init startup operations100
CASSANDRA_INIT_SLEEP_TIMESleep time for init startup operations5
CASSANDRA_PEER_CQL_MAX_RETRIESMaximum retries for peer startup operations100
CASSANDRA_PEER_CQL_SLEEP_TIMESleep time for peer startup operations10
CASSANDRA_DELAY_START_TIMEDelay Cassandra start by the number of provided seconds10
CASSANDRA_AUTO_SNAPSHOT_TTLTake an automatic snapshot of the data before truncating a keyspace or dropping a table30d
ALLOW_EMPTY_PASSWORDAllow no credentials in the installation.no
CASSANDRA_AUTHORIZERCassandra connection authorizerCassandraAuthorizer
CASSANDRA_AUTHENTICATORCassandra connection authenticatorPasswordAuthenticator
CASSANDRA_USERCassandra usernamecassandra
CASSANDRA_PASSWORDCassandra passwordnil
CASSANDRA_KEYSTORE_PASSWORDCassandra keystore passwordcassandra
CASSANDRA_TRUSTSTORE_PASSWORDCassandra truststore passwordcassandra
CASSANDRA_KEYSTORE_LOCATIONCassandra keystore location${DB_VOLUME_DIR}/secrets/keystore
CASSANDRA_TRUSTSTORE_LOCATIONCassandra truststore location${DB_VOLUME_DIR}/secrets/truststore
CASSANDRA_TMP_P12_FILECassandra truststore location${DB_TMP_DIR}/keystore.p12
CASSANDRA_SSL_CERT_FILECassandra SSL certificate location${DB_VOLUME_DIR}/certs/tls.crt
CASSANDRA_SSL_KEY_FILECassandra SSL keyfile location${DB_VOLUME_DIR}/certs/tls.key
CASSANDRA_SSL_CA_FILECassandra SSL CA locationnil
CASSANDRA_SSL_VALIDATEPerform SSL validation on the certificatesfalse
SSL_VERSIONTLS version to use when connecting.TLSv1_2
CASSANDRA_MOUNTED_CONF_DIRCassandra directory for mounted configuration files${DB_VOLUME_DIR}/conf
JAVA_TOOL_OPTIONSJava tool options.nil

Read-only environment variables

NameDescriptionValue
DB_FLAVORDatabase flavor. Valid values: cassandra or scylladb.cassandra
CASSANDRA_BASE_DIRCassandra installation directory/opt/bitnami/cassandra
CASSANDRA_BIN_DIRCassandra executables directory${DB_BASE_DIR}/bin
CASSANDRA_VOLUME_DIRPersistence base directory/bitnami/cassandra
CASSANDRA_DATA_DIRCassandra data directory${DB_VOLUME_DIR}/data
CASSANDRA_COMMITLOG_DIRCassandra commit log directory${DB_DATA_DIR}/commitlog
CASSANDRA_INITSCRIPTS_DIRPath to the Cassandra container init scripts directory/docker-entrypoint-initdb.d
CASSANDRA_LOG_DIRCassandra logs directory${DB_BASE_DIR}/logs
CASSANDRA_TMP_DIRCassandra temporary directory${DB_BASE_DIR}/tmp
JAVA_BASE_DIRJava base directory${BITNAMI_ROOT_DIR}/java
JAVA_BIN_DIRJava binary directory${JAVA_BASE_DIR}/bin
PYTHON_BASE_DIRPython base directory${BITNAMI_ROOT_DIR}/python
PYTHON_BIN_DIRPython binary directory${PYTHON_BASE_DIR}/bin
CASSANDRA_LOG_FILEPath to the Cassandra log file${DB_LOG_DIR}/cassandra.log
CASSANDRA_FIRST_BOOT_LOG_FILEPath to the Cassandra first boot log file${DB_LOG_DIR}/cassandra_first_boot.log
CASSANDRA_INITSCRIPTS_BOOT_LOG_FILEPath to the Cassandra init scripts log file${DB_LOG_DIR}/cassandra_init_scripts_boot.log
CASSANDRA_PID_FILEPath to the Cassandra pid file${DB_TMP_DIR}/cassandra.pid
CASSANDRA_DAEMON_USERCassandra system usercassandra
CASSANDRA_DAEMON_GROUPCassandra system groupcassandra
CASSANDRA_CONF_DIRCassandra configuration directory${DB_BASE_DIR}/conf
CASSANDRA_DEFAULT_CONF_DIRCassandra default configuration directory${DB_BASE_DIR}/conf.default
CASSANDRA_CONF_FILEPath to Cassandra configuration file${DB_CONF_DIR}/cassandra.yaml
CASSANDRA_RACKDC_FILEPath to Cassandra cassandra-rackdc.properties file${DB_CONF_DIR}/cassandra-rackdc.properties
CASSANDRA_LOGBACK_FILEPath to Cassandra logback.xml file${DB_CONF_DIR}/logback.xml
CASSANDRA_COMMITLOG_ARCHIVING_FILEPath to Cassandra commitlog_archiving.properties file${DB_CONF_DIR}/commitlog_archiving.properties
CASSANDRA_ENV_FILEPath to Cassandra cassandra-env.sh file${DB_CONF_DIR}/cassandra-env.sh
CASSANDRA_MOUNTED_CONF_PATHRelative path (in mounted volume) to Cassandra configuration filecassandra.yaml
CASSANDRA_MOUNTED_RACKDC_PATHRelative path (in mounted volume) to Cassandra cassandra-rackdc-properties filecassandra-rackdc.properties
CASSANDRA_MOUNTED_ENV_PATHRelative path (in mounted volume) to Cassandra cassandra-env.sh filecassandra-env.sh
CASSANDRA_MOUNTED_LOGBACK_PATHPath to Cassandra logback.xml filelogback.xml

Additionally, any environment variable beginning with the following prefix will be mapped to its corresponding Apache Cassandra key in the proper file:

  • CASSANDRA_CFG_ENV_: Will add the corresponding key and the provided value to cassandra-env.sh.
  • CASSANDRA_CFG_RACKDC_: Will add the corresponding key and the provided value to cassandra-rackdc.properties.
  • CASSANDRA_CFG_COMMITLOG_: Will add the corresponding key and the provided value to commitlog_archiving.properties.
  • CASSANDRA_CFG_YAML_: Will add the corresponding key and the provided value to cassandra.yaml.

For example, use CASSANDRA_CFG_RACKDC_PREFER_LOCAL=true in order to configure prefer_local in cassandra-rackdc.properties. Or, use CASSANDRA_CFG_YAML_INTERNODE_COMPRESSION=all in order to set internode_compression to all in cassandra.yaml.

NOTE: Environment variables will be omitted when mounting a configuration file

When you start the cassandra image, you can adjust the configuration of the instance by passing one or more environment variables either on the docker-compose file or on the docker run command line. If you want to add a new environment variable:

  • For docker-compose add the variable name and value under the application section:
cassandra:
  image: bitnami/cassandra:latest
  environment:
    - CASSANDRA_TRANSPORT_PORT_NUMBER=7000
  • For manual execution add a -e option with each variable and value:
 $ docker run --name cassandra -d -p 7000:7000 --network=cassandra_network \
    -e CASSANDRA_TRANSPORT_PORT_NUMBER=7000 \
    -v /your/local/path/bitnami/cassandra:/bitnami \
    bitnami/cassandra

Note: the README for this container is longer than the DockerHub length limit of 25000, so it has been trimmed. The full README can be found at https://github.com/bitnami/containers/blob/main/bitnami/cassandra/README.md

Docker Pull Command

docker pull bitnami/cassandra
Bitnami