0

I need to create a redis cluster environment in docker with 6 redis nodes deployed in 2 different servers, each with 3 nodes.

sample docker-compose.yml

version: '3.8'
networks:
  redis-cluster:
    driver: overlay
    external: true

services:
  redis-node-1:
    image: redis:7.0
    container_name: redis-node-1
    volumes:
      - ./config/redis-node1.conf:/usr/local/etc/redis/redis.conf
      - ./data/redis-node1:/data
      - ./logs/redis-node1:/var/log/redis
    ports:
      - "7001:6379"
      - "17001:16379"
    networks:
      redis-cluster:
        ipv4_address: 172.18.0.11
    command: redis-server /usr/local/etc/redis/redis.conf

redis-node1.conf

port 6379
bind 0.0.0.0
cluster-announce-ip 172.18.0.11
cluster-enabled yes
cluster-config-file nodes-7001.conf
cluster-node-timeout 5000
appendonly yes
dir /var/lib/redis/7001
logfile /var/log/redis/redis-7001.log
pidfile /var/run/redis-7001.pid
requirepass DevRedis01
masterauth DevRedis01
cluster-require-full-coverage no

I have created a network using following settings

docker swarm init --advertise-addr <server-ip>
docker swarm join --token <your-token> <manager-ip>:2377
docker network create --driver overlay --subnet=172.18.0.0/16 redis-cluster

Getting error as follows while using docker-compose

usert@ugat:sudo docker-compose up -d
WARNING: The Docker Engine you're using is running in swarm mode.
 
Compose does not use swarm mode to deploy services to multiple nodes in a swarm. All containers will be scheduled on the current node.
 
To deploy your application across the swarm, use `docker stack deploy`.
 
Starting redis-node-5 ... error
Starting redis-node-4 ...
Starting redis-node-6 ...
Starting redis-node-4 ... error
ERROR: for redis-node-5  Cannot start service redis-node-5: network redis-cluster not found
 
Starting redis-node-6 ... error
 
ERROR: for redis-node-6  Cannot start service redis-node-6: network redis-cluster not found
 
ERROR: for redis-node-5  Cannot start service redis-node-5: network redis-cluster not found
 
ERROR: for redis-node-4  Cannot start service redis-node-4: network redis-cluster not found
 
ERROR: for redis-node-6  Cannot start service redis-node-6: network redis-cluster not found
ERROR: Encountered errors while bringing up the project.

is there anything I missed while creating the network?

6
  • maybe you just need to call the network redis-cluster in the docker command instead of redis-cluster-net? I would also look into that warning in the beginning about not using compose with swarm. Commented Oct 25, 2024 at 10:32
  • I just pasted the template that's why the cluster name is different in the docker command...swarm is not needed for this implementation...that's why I skipped that part Commented Oct 27, 2024 at 6:19
  • if you don't run the code with swarm in it, I would edit it out of the question Commented Oct 28, 2024 at 10:25
  • for the communication between 2 nodes using the same docker network, i used this swarm...is there any alternative Commented Oct 28, 2024 at 11:16
  • I'm not really a docker expert. If it's communication between two containers I know you don't need swarm. Can use docker compose with multiple containers and they will talk through a network. But with nodes I don't know Commented Oct 28, 2024 at 13:11

0

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.