Score:0

Connect redis-cluster(running in docker) from host machine

fr flag
HDB

I have used docker-compose with static ip to create redis-cluster, everything ran successfully but now I am stuck at how do I connect my host application to redis-cluster running in side docker.

version: '3'
services:  
  hdbrediscluster:
    container_name: hdbrediscluster
    image: redis:6.2.7-alpine
    command: redis-cli --cluster create 172.20.0.10:6380 172.20.0.11:6381 172.20.0.12:6382 172.20.0.13:6383 172.20.0.14:6384 172.20.0.15:6385 --cluster-replicas 1 --cluster-yes
    networks:
      database:
        ipv4_address: 172.20.0.9
    ports:
      - 6379:6379
    depends_on:
      - hdbredisnode1
      - hdbredisnode2
      - hdbredisnode3
      - hdbredisnode4
      - hdbredisnode5
      - hdbredisnode6

  hdbredisnode1:
    container_name: hdbredisnode1
    image: redis:6.2.7-alpine
    command: redis-server /usr/local/etc/redis/redis.conf
    volumes:
      - "/Users/hiteshbaldaniya/Projects/Dockers/redis/node1:/var/lib/redis"
      - "/Users/hiteshbaldaniya/Projects/Dockers/redis/config/node1.conf:/usr/local/etc/redis/redis.conf"
    networks:
      database:
        ipv4_address: 172.20.0.10
    ports:
      - 6380:6380

  hdbredisnode2:
    container_name: hdbredisnode2
    image: redis:6.2.7-alpine
    command: redis-server /usr/local/etc/redis/redis.conf
    volumes:
      - "/Users/hiteshbaldaniya/Projects/Dockers/redis/node2:/var/lib/redis"
      - "/Users/hiteshbaldaniya/Projects/Dockers/redis/config/node2.conf:/usr/local/etc/redis/redis.conf"
    networks:
      database:
        ipv4_address: 172.20.0.11
    ports:
      - 6381:6381

  hdbredisnode3:
    container_name: hdbredisnode3
    image: redis:6.2.7-alpine
    command: redis-server /usr/local/etc/redis/redis.conf
    volumes:
      - "/Users/hiteshbaldaniya/Projects/Dockers/redis/node3:/var/lib/redis"
      - "/Users/hiteshbaldaniya/Projects/Dockers/redis/config/node3.conf:/usr/local/etc/redis/redis.conf"
    networks:
      database:
        ipv4_address: 172.20.0.12
    ports:
      - 6382:6382

  hdbredisnode4:
    container_name: hdbredisnode4
    image: redis:6.2.7-alpine
    command: redis-server /usr/local/etc/redis/redis.conf
    volumes:
      - "/Users/hiteshbaldaniya/Projects/Dockers/redis/node4:/var/lib/redis"
      - "/Users/hiteshbaldaniya/Projects/Dockers/redis/config/node4.conf:/usr/local/etc/redis/redis.conf"
    networks:
      database:
        ipv4_address: 172.20.0.13
    ports:
      - 6383:6383

  hdbredisnode5:
    container_name: hdbredisnode5
    image: redis:6.2.7-alpine
    command: redis-server /usr/local/etc/redis/redis.conf
    volumes:
      - "/Users/hiteshbaldaniya/Projects/Dockers/redis/node5:/var/lib/redis"
      - "/Users/hiteshbaldaniya/Projects/Dockers/redis/config/node5.conf:/usr/local/etc/redis/redis.conf"
    networks:
      database:
        ipv4_address: 172.20.0.14
    ports:
      - 6384:6384

  hdbredisnode6:
    container_name: hdbredisnode6
    image: redis:6.2.7-alpine
    command: redis-server /usr/local/etc/redis/redis.conf
    volumes:
      - "/Users/hiteshbaldaniya/Projects/Dockers/redis/node6:/var/lib/redis"
      - "/Users/hiteshbaldaniya/Projects/Dockers/redis/config/node6.conf:/usr/local/etc/redis/redis.conf"
    networks:
      database:
        ipv4_address: 172.20.0.15
    ports:
      - 6385:6385

networks:
  database:
    name: database
    driver: bridge
    ipam:
      config:
        - subnet: 172.20.0.0/16

FYI, I am using java vertx redis client to connect. Please let me know the solution also I have assigned subnet random IP address. Also, I am working on macos. Docker version: 4.8.2 (79419)

mangohost

Post an answer

Most people don’t grasp that asking a lot of questions unlocks learning and improves interpersonal bonding. In Alison’s studies, for example, though people could accurately recall how many questions had been asked in their conversations, they didn’t intuit the link between questions and liking. Across four studies, in which participants were engaged in conversations themselves or read transcripts of others’ conversations, people tended not to realize that question asking would influence—or had influenced—the level of amity between the conversationalists.