docker.recipes

Hazelcast

intermediate

In-memory data grid with distributed caching and computing.

Overview

Hazelcast is an open-source in-memory data grid platform that provides distributed caching, computing, and storage capabilities across clusters of servers. Originally developed in 2008, Hazelcast enables applications to share data and computation across multiple nodes, offering both high availability and horizontal scalability. The platform supports various data structures including maps, queues, topics, and sets, all distributed and replicated across cluster members for fault tolerance. This Docker stack combines the core Hazelcast server with the Management Center web interface, creating a complete distributed caching solution. The Hazelcast node handles data storage, replication, and client connections, while the Management Center provides real-time monitoring, cluster management, and administrative tools through a web dashboard. The two components communicate over the internal network, with the Management Center automatically discovering and connecting to cluster members. This combination is ideal for development teams building distributed applications that require low-latency data access, session sharing, or real-time analytics. The stack provides immediate value for microservices architectures needing shared state, Java applications requiring distributed caching, and organizations implementing event-driven architectures with stream processing capabilities.

Key Features

  • Distributed hash maps with automatic partitioning and replication across cluster nodes
  • Built-in Jet stream processing engine for real-time data analytics and ETL operations
  • SQL query support for distributed data structures using standard ANSI SQL syntax
  • Near-cache implementation providing client-side caching for sub-millisecond access times
  • Management Center web interface with cluster topology visualization and performance metrics
  • Automatic cluster member discovery and dynamic scaling without manual configuration
  • Event-driven architecture support with distributed topics and reliable message delivery
  • CP Subsystem for strong consistency guarantees using Raft consensus algorithm

Common Use Cases

  • 1Microservices session storage sharing user sessions across multiple application instances
  • 2Real-time leaderboards and gaming statistics requiring ultra-low latency data access
  • 3Financial trading platforms needing distributed reference data caching and risk calculations
  • 4E-commerce applications caching product catalogs and inventory data across regions
  • 5IoT data ingestion and stream processing for sensor data analytics and alerting
  • 6Application-level database query result caching to reduce database load
  • 7Distributed computing workloads requiring map-reduce style data processing across nodes

Prerequisites

  • Minimum 2GB RAM available as Hazelcast requires substantial memory for in-memory operations
  • Port 5701 available for Hazelcast client connections and cluster communication
  • Port 8080 free for Management Center web interface access
  • Java application development knowledge for implementing Hazelcast clients
  • Understanding of distributed systems concepts like partitioning and replication
  • Network connectivity between client applications and Docker host for cluster access

For development & testing. Review security settings, change default credentials, and test thoroughly before production use. See Terms

docker-compose.yml

docker-compose.yml
1services:
2 hazelcast:
3 image: hazelcast/hazelcast:latest
4 container_name: hazelcast
5 restart: unless-stopped
6 environment:
7 HZ_CLUSTERNAME: dev
8 ports:
9 - "5701:5701"
10 networks:
11 - hz-network
12
13 management-center:
14 image: hazelcast/management-center:latest
15 container_name: hz-management
16 restart: unless-stopped
17 environment:
18 MC_DEFAULT_CLUSTER: dev
19 MC_DEFAULT_CLUSTER_MEMBERS: hazelcast:5701
20 ports:
21 - "8080:8080"
22 depends_on:
23 - hazelcast
24 networks:
25 - hz-network
26
27networks:
28 hz-network:
29 driver: bridge

.env Template

.env
1# Hazelcast default configuration

Usage Notes

  1. 1Docs: https://docs.hazelcast.com/
  2. 2Management Center at http://localhost:8080 | Client port 5701
  3. 3Near-cache support - client-side caching for lowest latency
  4. 4SQL over distributed data - query maps with standard SQL
  5. 5Jet engine for stream processing and real-time analytics
  6. 6Automatic cluster discovery and data partitioning

Individual Services(2 services)

Copy individual services to mix and match with your existing compose files.

hazelcast
hazelcast:
  image: hazelcast/hazelcast:latest
  container_name: hazelcast
  restart: unless-stopped
  environment:
    HZ_CLUSTERNAME: dev
  ports:
    - "5701:5701"
  networks:
    - hz-network
management-center
management-center:
  image: hazelcast/management-center:latest
  container_name: hz-management
  restart: unless-stopped
  environment:
    MC_DEFAULT_CLUSTER: dev
    MC_DEFAULT_CLUSTER_MEMBERS: hazelcast:5701
  ports:
    - "8080:8080"
  depends_on:
    - hazelcast
  networks:
    - hz-network

Quick Start

terminal
1# 1. Create the compose file
2cat > docker-compose.yml << 'EOF'
3services:
4 hazelcast:
5 image: hazelcast/hazelcast:latest
6 container_name: hazelcast
7 restart: unless-stopped
8 environment:
9 HZ_CLUSTERNAME: dev
10 ports:
11 - "5701:5701"
12 networks:
13 - hz-network
14
15 management-center:
16 image: hazelcast/management-center:latest
17 container_name: hz-management
18 restart: unless-stopped
19 environment:
20 MC_DEFAULT_CLUSTER: dev
21 MC_DEFAULT_CLUSTER_MEMBERS: hazelcast:5701
22 ports:
23 - "8080:8080"
24 depends_on:
25 - hazelcast
26 networks:
27 - hz-network
28
29networks:
30 hz-network:
31 driver: bridge
32EOF
33
34# 2. Create the .env file
35cat > .env << 'EOF'
36# Hazelcast default configuration
37EOF
38
39# 3. Start the services
40docker compose up -d
41
42# 4. View logs
43docker compose logs -f

One-Liner

Run this command to download and set up the recipe in one step:

terminal
1curl -fsSL https://docker.recipes/api/recipes/hazelcast/run | bash

Troubleshooting

  • Management Center shows 'Unable to connect to cluster': Verify HZ_CLUSTERNAME matches MC_DEFAULT_CLUSTER environment variables
  • Client connection refused on port 5701: Check Docker host firewall and ensure port mapping is active with netstat -tulpn
  • Cluster member not visible in Management Center: Confirm MC_DEFAULT_CLUSTER_MEMBERS points to correct container name and port
  • OutOfMemoryError in Hazelcast logs: Increase Docker container memory limits or reduce map size configurations
  • Split-brain scenario with multiple clusters: Ensure consistent cluster naming and implement proper network partitioning handling
  • Slow query performance on distributed maps: Enable indexes on frequently queried fields and optimize SQL predicates

Community Notes

Loading...
Loading notes...

Download Recipe Kit

Get all files in a ready-to-deploy package

Includes docker-compose.yml, .env template, README, and license

Components

hazelcastmanagement-center

Tags

#hazelcast#in-memory#cache#distributed#grid

Category

Database Stacks
Ad Space