Redis Cluster
Swarm
Open-source in-memory data structure store - Cluster mode
Services
redis-node-0
Configuration
Imagedocker.io/bitnami/redis-cluster:6.2/bitnami/redis/data : redis-cluster_data-0REDIS_PASSWORD=${REDIS_PASSWD}REDIS_NODES=redis-node-0 redis-node-1 redis-node-2Image details
redis-node-1
Configuration
Imagedocker.io/bitnami/redis-cluster:6.2/bitnami/redis/data : redis-cluster_data-1REDIS_PASSWORD=${REDIS_PASSWD}REDIS_NODES=redis-node-0 redis-node-1 redis-node-2Image details
redis-node-2
Configuration
Imagedocker.io/bitnami/redis-cluster:6.2/bitnami/redis/data : redis-cluster_data-2REDIS_PASSWORD=${REDIS_PASSWD}REDISCLI_AUTH=${REDIS_PASSWD}REDIS_CLUSTER_REPLICAS=0REDIS_NODES=redis-node-0 redis-node-1 redis-node-2REDIS_CLUSTER_CREATOR=yesImage details
Standalone Install
Select an install method, to see config/commands for deploying Redis Cluster
Install on Portainer
Import all app templates into your Portainer instance, for easy 1-click deploys
- Ensure both Docker and Portainer are installed, and up-to-date
- Log into your Portainer web UI
- Under Settings → App Templates, paste the below URL
- Head to Home → App Templates, and the list of apps will show up
- Select Redis Cluster, fill in any config options, and hit Deploy
Template Import URL
https://raw.githubusercontent.com/Lissy93/portainer-templates/main/templates.json
Show Me
Original stackfile
The swarm stack file this template deploys, straight from its repo:
version: "3.6"
services:
redis-node-0:
image: docker.io/bitnami/redis-cluster:6.2
volumes:
- redis-cluster_data-0:/bitnami/redis/data
environment:
- "REDIS_PASSWORD=${REDIS_PASSWD}"
- "REDIS_NODES=redis-node-0 redis-node-1 redis-node-2"
redis-node-1:
image: docker.io/bitnami/redis-cluster:6.2
volumes:
- redis-cluster_data-1:/bitnami/redis/data
environment:
- "REDIS_PASSWORD=${REDIS_PASSWD}"
- "REDIS_NODES=redis-node-0 redis-node-1 redis-node-2"
redis-node-2:
image: docker.io/bitnami/redis-cluster:6.2
volumes:
- redis-cluster_data-2:/bitnami/redis/data
depends_on:
- redis-node-0
- redis-node-1
environment:
- "REDIS_PASSWORD=${REDIS_PASSWD}"
- "REDISCLI_AUTH=${REDIS_PASSWD}"
- "REDIS_CLUSTER_REPLICAS=0"
- "REDIS_NODES=redis-node-0 redis-node-1 redis-node-2"
- "REDIS_CLUSTER_CREATOR=yes"
volumes:
redis-cluster_data-0:
redis-cluster_data-1:
redis-cluster_data-2:
Or deploy it directly from the source:
git clone https://github.com/portainer/templates
cd templates
docker stack deploy -c stacks/redis-cluster/docker-stack.yaml redis-clusterMore install options in our documentation.
Container Documentation
redis-node-0 Documentation
Bitnami Secure Image for redis-cluster
redis-node-1 Documentation
Bitnami Secure Image for redis-cluster
redis-node-2 Documentation
Bitnami Secure Image for redis-cluster
Check the logs first
Nine times out of ten the logs tell you exactly what went wrong.
- In Portainer, go to Containers, click the container, then Logs. Or run
docker logs <container> - Exit codes help too:
137means killed, usually out of memory.126or127means the command inside the image is broken.
Image won't pull
Test the pull directly on the host: docker pull docker.io/bitnami/redis-cluster:6.2
- "manifest unknown" means the tag no longer exists.
- "toomanyrequests" is the Docker Hub rate limit. Log in with
docker loginto raise it. - "no space left on device" means a full disk. Reclaim space with
docker system prune
"exec format error"
This means the image was built for a different CPU architecture than your server.
- Check yours with
uname -m: x86_64 is amd64, aarch64 is arm64. Raspberry Pi and other ARM boards are the usual culprits.
Stack won't deploy
Compose stacks fail fast on small mistakes, and Portainer shows the reason just above the editor.
- YAML only accepts spaces for indentation, a single tab breaks the whole file.
Raise an issue
Found something which isn't working as it should? Here's how to report it.
- Bug within the app: Open an issue within redis-node-0's repo
- Template not working: Open an issue on portainer/templates
- This website not working: Open an issue on lissy93/portainer-templates
A Swarm stack
Redis Cluster is a Swarm stack. Swarm is Docker's own way of running apps across more than one machine, so Portainer can spread it over a cluster and move it elsewhere if a server drops out.
The services
This stack is built from 3 containers that run side by side. Here's each one, with the image it runs and anything it waits for first:
redis-node-0runsdocker.io/bitnami/redis-cluster:6.2redis-node-1runsdocker.io/bitnami/redis-cluster:6.2redis-node-2runsdocker.io/bitnami/redis-cluster:6.2, starts after redis-node-0, redis-node-1
Volumes
A volume is where Redis Cluster keeps its files so they survive an update or a restart. Without one, anything it saves would sit inside the container and vanish the moment it's recreated. This template mounts:
/bitnami/redis/datakept in theredis-cluster_data-0volume Docker manages/bitnami/redis/datakept in theredis-cluster_data-1volume Docker manages/bitnami/redis/datakept in theredis-cluster_data-2volume Docker manages
Environment variables
Environment variables are the settings you hand over when you deploy, things like a password or a timezone. Redis Cluster takes 5 of them, all with defaults you can leave alone or tweak:
REDIS_PASSWORD, pulled from your own environmentREDIS_NODES, defaults toredis-node-0 redis-node-1 redis-node-2REDISCLI_AUTH, pulled from your own environmentREDIS_CLUSTER_REPLICAS, defaults to0REDIS_CLUSTER_CREATOR, defaults toyes
Networking
Portainer puts these services on one shared private network, so they can find each other by name (like redis-node-0) while only the ports above are open to you.
Platform
The platform is linux, the kind of system the container is built to run on. Docker and Portainer handle this on a normal Linux server.
Portainer app templates
Zooming out, this whole page comes from a Portainer app template: a short recipe telling Portainer how to set Redis Cluster up. Add the template list to Portainer once, then deploying Redis Cluster is a click rather than a wall of config.