services: cassandra1: build: . container_name: cassandra1 env_file: - .env environment: - CASSANDRA_BROADCAST_ADDRESS=cassandra1 - CASSANDRA_LISTEN_ADDRESS=cassandra1 - CASSANDRA_RPC_ADDRESS=cassandra1 - CASSANDRA_DC=DC1 - CASSANDRA_RACK=RAC1 - PRIMARY_NODE=true volumes: - ./scripts:/scripts - ./data/dumps/node1:/dump/snapshot - ./data/dumps/schema:/dump/schema - ./data/volumes/node1:/var/lib/cassandra - ./data/logs/node1:/var/log/cassandra healthcheck: test: ["CMD-SHELL", "nodetool status"] interval: 2m start_period: 2m timeout: 10s retries: 3 ports: - "9042:9042" # Cassandra default port for CQL networks: - cassandra-net restart: on-failure cassandra2: build: . container_name: cassandra2 env_file: - .env environment: - CASSANDRA_BROADCAST_ADDRESS=cassandra2 - CASSANDRA_LISTEN_ADDRESS=cassandra2 - CASSANDRA_RPC_ADDRESS=cassandra2 - CASSANDRA_DC=DC1 - CASSANDRA_RACK=RAC1 - PRIMARY_NODE=false healthcheck: test: ["CMD-SHELL", "nodetool status"] interval: 2m start_period: 2m timeout: 10s retries: 3 volumes: - ./scripts:/scripts - ./data/dumps/node2:/dump/snapshot - ./data/dumps/schema:/dump/schema - ./data/volumes/node2:/var/lib/cassandra - ./data/logs/node2:/var/log/cassandra networks: - cassandra-net depends_on: cassandra1: condition: service_healthy ports: - "9043:9042" # Cassandra instance 2 CQL port restart: on-failure cassandra3: build: . container_name: cassandra3 env_file: - .env environment: - CASSANDRA_BROADCAST_ADDRESS=cassandra3 - CASSANDRA_LISTEN_ADDRESS=cassandra3 - CASSANDRA_RPC_ADDRESS=cassandra3 - CASSANDRA_DC=DC1 - CASSANDRA_RACK=RAC1 - PRIMARY_NODE=false healthcheck: test: ["CMD-SHELL", "nodetool status"] interval: 2m start_period: 2m timeout: 10s retries: 3 volumes: - ./scripts:/scripts - ./data/dumps/node3:/dump/snapshot - ./data/dumps/schema:/dump/schema - ./data/volumes/node3:/var/lib/cassandra - ./data/logs/node3:/var/log/cassandra networks: - cassandra-net depends_on: cassandra2: condition: service_healthy ports: - "9044:9042" # Cassandra instance 3 CQL port restart: on-failure networks: cassandra-net: driver: bridge