Install Cassandra with Docker
The EASIEST way to run Cassandra - Works on Windows, macOS, and Linux!
๐ณ Docker: The EASIEST Way to Run Cassandra!
โ Why Docker is AMAZING for Cassandra
- ๐ 1 Command Setup: Running in 30 seconds!
- ๐ป Works Everywhere: Windows, macOS, Linux - same commands
- ๐งน Clean Isolation: No system pollution
- ๐ Easy Reset: Delete and recreate instantly
- ๐ฆ Consistent Environment: Same as production
- ๐ Multi-Node Clusters: Test clusters on your laptop!
- โก Version Switching: Try different Cassandra versions easily
๐ก Perfect Use Cases
- โ Learning Cassandra: Fastest way to get started
- โ Local Development: No conflicts with your system
- โ Testing: Spin up/down clusters instantly
- โ CI/CD Pipelines: Automated testing
- โ Multi-Node Experiments: Test replication locally
- โ Windows/Mac Users: Get Linux environment easily
๐ฏ What You'll Learn
- ๐ณ Install Docker Desktop (any OS)
- ๐ฆ Run single Cassandra container
- ๐ผ Use Docker Compose for easy management
- ๐ Create 3-node Cassandra cluster
- ๐พ Persist data with volumes
- โ๏ธ Essential Docker commands
๐ Let's get Cassandra running with Docker - it's SUPER easy!
๐ณ Step 1: Install Docker Desktop
First, install Docker Desktop for your operating system.
Windows
- Download Docker Desktop from
docker.com - Run installer (requires WSL 2)
- Restart computer
- Start Docker Desktop
macOS
- Download Docker Desktop from
docker.com - Drag to Applications
- Open Docker Desktop
- Wait for startup
Linux
Verify Docker Installation
๐ฆ Method 1: Single Container Setup
The quickest way to get Cassandra running!
Run Cassandra Container
Literally ONE command!
โฑ๏ธ Wait 30-60 seconds for Cassandra to start!
Check Container Status
Connect with cqlsh
That's It! Cassandra is Running! ๐
You now have a working Cassandra instance!
- โ Cassandra running on port 9042
- โ Can connect from your host machine
- โ cqlsh available inside container
- โ Ready to learn and experiment!
Important: Data is NOT Persisted!
If you delete the container, all data is lost. To persist data, see the Data Persistence section below.
๐ผ Method 2: Docker Compose (Recommended)
Better way to manage Cassandra - configuration as code!
Create docker-compose.yml
Create a file called docker-compose.yml:
Start with Docker Compose
Connect and Use
Why Docker Compose is Better
- โ Easy Management: One command to start/stop
- โ Configuration File: Version control your setup
- โ Data Persistence: Volumes configured automatically
- โ Multi-Container: Easy to add more nodes
- โ Environment Variables: Easy customization
๐ Method 3: Multi-Node Cluster
Create a 3-node Cassandra cluster on your laptop!
Create docker-compose-cluster.yml
Start the Cluster
Test Replication
You Just Created a Real Cassandra Cluster! ๐
This is amazing for learning:
- โ Test replication across nodes
- โ Practice with multi-datacenter concepts
- โ Simulate node failures
- โ Learn cluster operations
- โ All on your laptop!
๐พ Data Persistence with Volumes
Make sure your data survives container restarts!
Why Volumes Matter
Without volumes: Deleting container = losing all data
With volumes: Data persists even after container deletion
Single Container with Volume
Manage Volumes
Backup Data from Volume
โ๏ธ Essential Docker Commands
Cheat sheet for managing Cassandra containers!
๐ Starting & Stopping
๐ Monitoring
๐ป Executing Commands
๐๏ธ Cleanup
๐ Debugging
๐ง Common Issues & Solutions
Fix common Docker + Cassandra problems!
โ Container starts but immediately stops
Problem: Not enough memory or port conflict
Solutions:
- Check Docker Desktop has at least 4GB RAM allocated
- Check if port 9042 is already in use:
lsof -i :9042 - View logs:
docker logs cassandra-node
โ "Cannot connect to CQL"
Problem: Cassandra not fully started
Solution:
โ Nodes not joining cluster
Problem: Network or timing issue
Solutions:
- Start nodes one at a time with 30s delay between each
- Check network:
docker network inspect cassandra-network - Verify CASSANDRA_SEEDS is set correctly
- Start fresh:
docker-compose down -v && docker-compose up -d
โ "Port is already allocated"
Problem: Another process using port 9042
Solution:
โ Docker Desktop not starting (Windows)
Problem: WSL 2 or Hyper-V issues
Solutions:
- Enable WSL 2:
wsl --installin PowerShell (Admin) - Update WSL:
wsl --update - Enable Hyper-V in Windows Features
- Restart computer
โ Very slow performance
Problem: Docker resource limits
Solution:
Increase Docker Desktop resources:
- Memory: At least 4GB (8GB recommended)
- CPU: At least 2 cores (4 recommended)
- Disk: At least 20GB
Settings โ Resources โ Adjust values
Nuclear Option: Start Fresh
If nothing works:
๐ Docker + Cassandra = Perfect Match!
Congratulations! You now know how to run Cassandra with Docker!
๐ What You Learned:
- ๐ณ Single container: Quick setup in 1 command
- ๐ผ Docker Compose: Better management with config files
- ๐ Multi-node cluster: 3-node cluster on your laptop!
- ๐พ Data persistence: Volumes to keep your data safe
- โ๏ธ Essential commands: Manage, monitor, and debug
๐ก Quick Reference:
๐ณ Docker makes learning Cassandra SO much easier!
Responsive Ad