version: "3.7" x-default: &defaults privileged: true build: context: redis-cluster restart: always stdin_open: true tty: true services: redis1: <<: *defaults container_name: redis1 ports: - "0.0.0.0:6379:6379" - "0.0.0.0:16379:16379" volumes: - ./redis-cluster/conf/redis1.conf:/etc/redis.conf:rw - ${DATA_PATH}/redis1:/data:rw redis2: <<: *defaults container_name: redis2 ports: - "0.0.0.0:6380:6379" - "0.0.0.0:16380:16379" volumes: - ./redis-cluster/conf/redis2.conf:/etc/redis.conf:rw - ${DATA_PATH}/redis2:/data:rw redis3: <<: *defaults container_name: redis3 ports: - "0.0.0.0:6381:6379" - "0.0.0.0:16381:16379" volumes: - ./redis-cluster/conf/redis3.conf:/etc/redis.conf:rw - ${DATA_PATH}/redis3:/data:rw redis4: <<: *defaults container_name: redis4 ports: - "0.0.0.0:6382:6379" - "0.0.0.0:16382:16379" volumes: - ./redis-cluster/conf/redis4.conf:/etc/redis.conf:rw - ${DATA_PATH}/redis4:/data:rw depends_on: - redis1 - redis2 - redis3 redis5: <<: *defaults container_name: redis5 ports: - "0.0.0.0:6383:6379" - "0.0.0.0:16383:16379" volumes: - ./redis-cluster/conf/redis5.conf:/etc/redis.conf:rw - ${DATA_PATH}/redis5:/data:rw depends_on: - redis1 - redis2 - redis3 redis6: <<: *defaults container_name: redis6 ports: - "0.0.0.0:6384:6379" - "0.0.0.0:16384:16379" volumes: - ./redis-cluster/conf/redis6.conf:/etc/redis.conf:rw - ${DATA_PATH}/redis6:/data:rw depends_on: - redis1 - redis2 - redis3 redis_cluster_creator: container_name: redis_cluster_creator privileged: true image: redis:5.0.11 entrypoint: [ /bin/sh,-c,'echo "yes" | redis-cli --cluster create 172.17.0.1:6379 172.17.0.1:6380 172.17.0.1:6381 172.17.0.1:6382 172.17.0.1:6383 172.17.0.1:6384 --cluster-replicas 1' ] ports: - "0.0.0.0:6385:6379" - "0.0.0.0:16385:16379" depends_on: - redis1 - redis2 - redis3 - redis4 - redis5 - redis6 # redis_cluster_creator: # container_name: redis_cluster_creator # privileged: true # ports: # - "0.0.0.0:6385:6379" # - "0.0.0.0:16385:16379" # build: # context: redis-cluster-creator # depends_on: # - redis1 # - redis2 # - redis3 # - redis4 # - redis5 # - redis6