Skip to content

Instantly share code, notes, and snippets.

@supercaracal
Last active December 31, 2023 16:16
Show Gist options
  • Save supercaracal/11ea2a4ab626f468810b625b00ee0f36 to your computer and use it in GitHub Desktop.
Save supercaracal/11ea2a4ab626f468810b625b00ee0f36 to your computer and use it in GitHub Desktop.
Redis Cluster Docker Compose example
---
services:
node1: &node
image: "redis:6.2.6"
command: >
redis-server
--maxmemory 64mb
--maxmemory-policy allkeys-lru
--appendonly yes
--cluster-enabled yes
--cluster-config-file nodes.conf
--cluster-node-timeout 5000
healthcheck:
test: ["CMD", "redis-cli", "ping"]
interval: "5s"
timeout: "3s"
retries: 10
ports:
- "7000:6379"
node2:
<<: *node
ports:
- "7001:6379"
node3:
<<: *node
ports:
- "7002:6379"
node4:
<<: *node
ports:
- "7003:6379"
node5:
<<: *node
ports:
- "7004:6379"
node6:
<<: *node
ports:
- "7005:6379"
clustering:
image: "redis:6.2.6"
command: >
bash -c "apt-get update > /dev/null
&& apt-get install --no-install-recommends --no-install-suggests -y dnsutils > /dev/null
&& rm -rf /var/lib/apt/lists/*
&& yes yes | redis-cli --cluster create
$$(dig node1 +short):6379
$$(dig node2 +short):6379
$$(dig node3 +short):6379
$$(dig node4 +short):6379
$$(dig node5 +short):6379
$$(dig node6 +short):6379
--cluster-replicas 1"
depends_on:
node1:
condition: service_healthy
node2:
condition: service_healthy
node3:
condition: service_healthy
node4:
condition: service_healthy
node5:
condition: service_healthy
node6:
condition: service_healthy
@supercaracal
Copy link
Author

supercaracal commented Oct 23, 2021

It is for testing purpose. It is unsuitable for clients on host machines with Docker desktop environment.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment