title: Redis Cluster Docker Compose
body: <p>I'm struggling to create a Docker Compose to create a Redis Cluster. I saw that there is a Redis Cluster image from Bitnami, I tried but it my Spring Boot App cannot connect to it due to the below error:
  <a href="https://i.stack.imgur.com/BX3mN.jpg" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/BX3mN.jpg" alt="enter image description here" /></a></p>
  <p>I tried another approach is to create 2 Redis instances master-slave and I can connect to it. Now I'm trying to create 6 Redis Instances and later create a Redis Cluster with 3 master and 3 slaves with the following command:</p>
  <pre><code>redis-cli --cluster create 127.0.0.1:6380 127.0.0.1:6381 \
  127.0.0.1:6382 127.0.0.1:6383 127.0.0.1:6384 127.0.0.1:6385 --cluster-replicas 1
  </code></pre>
  <p>But when I executed the command it said that</p>
  <pre><code>Could not connect to Redis at 127.0.0.1:6380: Connection refused
  </code></pre>
  <p>Below is my current Docker-compose.yaml:</p>
  <pre><code>version: '3.8'
  services:
    redis-node-0:
      image: redis:latest
      container_name: redis-0
      ports:
        - &quot;6380:6379&quot;
      command: [&quot;redis-server&quot;,&quot;--appendonly yes&quot;,&quot;--cluster-enabled yes&quot;,&quot;--cluster-node-timeout 5000&quot;]
      volumes:
        - redis-cluster_data-0:/redis/data
  
    redis-node-1:
      image: redis:latest
      container_name: redis-1
      ports:
        - &quot;6381:6379&quot;
      command: [&quot;redis-server&quot;,&quot;--appendonly yes&quot;,&quot;--cluster-enabled yes&quot;,&quot;--cluster-node-timeout 5000&quot;]  
      volumes:
        - redis-cluster_data-1:/redis/data
  
    redis-node-2:
      image: redis:latest
      container_name: redis-2
      ports:
        - &quot;6382:6379&quot;
      command: [&quot;redis-server&quot;,&quot;--appendonly yes&quot;,&quot;--cluster-enabled yes&quot;,&quot;--cluster-node-timeout 5000&quot;]
      volumes:
        - redis-cluster_data-2:/redis/data
  
    redis-node-3:
      image: redis:latest
      container_name: redis-3
      ports:
        - &quot;6383:6379&quot;
      command: [&quot;redis-server&quot;,&quot;--appendonly yes&quot;,&quot;--cluster-enabled yes&quot;,&quot;--cluster-node-timeout 5000&quot;]
      volumes:
        - redis-cluster_data-3:/redis/data
  
    redis-node-4:
      image: redis:latest
      container_name: redis-4
      ports:
        - &quot;6384:6379&quot;
      command: [&quot;redis-server&quot;,&quot;--appendonly yes&quot;,&quot;--cluster-enabled yes&quot;,&quot;--cluster-node-timeout 5000&quot;]
      volumes:
        - redis-cluster_data-4:/redis/data
  
    redis-node-5:
      image: redis:latest
      container_name: redis-5
      ports:
        - &quot;6385:6379&quot;
      command: [&quot;redis-server&quot;,&quot;--appendonly yes&quot;,&quot;--cluster-enabled yes&quot;,&quot;--cluster-node-timeout 5000&quot;]
      volumes:
        - redis-cluster_data-5:/redis/data
  
  
  networks: 
    default:
      name: overlay
  volumes:
    redis-cluster_data-0:
      driver: local
    redis-cluster_data-1:
      driver: local
    redis-cluster_data-2:
      driver: local
    redis-cluster_data-3:
      driver: local
    redis-cluster_data-4:
      driver: local
    redis-cluster_data-5:
      driver: local
  </code></pre>
  <p>I'm totally new to Both Docker and Redis, I'm learning so any help would be really appreciated. Thanks in advance.</p>