Skip to content

Instantly share code, notes, and snippets.

@kid1412621
Last active February 27, 2024 07:20
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save kid1412621/375b59ebf9980f416ea74994accde903 to your computer and use it in GitHub Desktop.
Save kid1412621/375b59ebf9980f416ea74994accde903 to your computer and use it in GitHub Desktop.
docker compose yaml
# without zookeeper
version: "3"
volumes:
broker0:
broker1:
broker2:
services:
broker0:
image: 'bitnami/kafka:latest'
container_name: broker0
environment:
KAFKA_ENABLE_KRAFT: yes
KAFKA_CFG_PROCESS_ROLES: 'broker,controller'
KAFKA_CFG_CONTROLLER_LISTENER_NAMES: 'CONTROLLER'
KAFKA_CFG_INTER_BROKER_LISTENER_NAME: 'INTERNAL'
KAFKA_CFG_LISTENERS: INTERNAL://:9094,CONTROLLER://:9093,EXTERNAL://:9092
KAFKA_CFG_LISTENER_SECURITY_PROTOCOL_MAP: CONTROLLER:PLAINTEXT,INTERNAL:PLAINTEXT,EXTERNAL:PLAINTEXT
KAFKA_CFG_ADVERTISED_LISTENERS: INTERNAL://broker0:9094,EXTERNAL://localhost:9092
KAFKA_CFG_NODE_ID: 0
KAFKA_CFG_CONTROLLER_QUORUM_VOTERS: '0@broker0:9093,1@broker1:9093,2@broker2:9093'
ALLOW_PLAINTEXT_LISTENER: yes
KAFKA_KRAFT_CLUSTER_ID: 7PnqRPczTWyvtndf7WgrYw
ports:
- "9092:9092"
volumes:
- broker0:/bitnami/kafka
broker1:
image: 'bitnami/kafka:latest'
container_name: broker1
environment:
KAFKA_ENABLE_KRAFT: yes
KAFKA_CFG_PROCESS_ROLES: 'broker,controller'
KAFKA_CFG_CONTROLLER_LISTENER_NAMES: 'CONTROLLER'
KAFKA_CFG_INTER_BROKER_LISTENER_NAME: 'INTERNAL'
KAFKA_CFG_LISTENERS: INTERNAL://:9094,CONTROLLER://:9093,EXTERNAL://:9092
KAFKA_CFG_LISTENER_SECURITY_PROTOCOL_MAP: CONTROLLER:PLAINTEXT,INTERNAL:PLAINTEXT,EXTERNAL:PLAINTEXT
KAFKA_CFG_ADVERTISED_LISTENERS: INTERNAL://broker1:9094,EXTERNAL://localhost:9192
KAFKA_CFG_NODE_ID: 1
KAFKA_CFG_CONTROLLER_QUORUM_VOTERS: '0@broker0:9093,1@broker1:9093,2@broker2:9093'
ALLOW_PLAINTEXT_LISTENER: yes
KAFKA_KRAFT_CLUSTER_ID: 7PnqRPczTWyvtndf7WgrYw
ports:
- "9192:9092"
volumes:
- broker1:/bitnami/kafka
broker2:
image: 'bitnami/kafka:latest'
container_name: broker2
environment:
KAFKA_ENABLE_KRAFT: yes
KAFKA_CFG_PROCESS_ROLES: 'broker,controller'
KAFKA_CFG_CONTROLLER_LISTENER_NAMES: 'CONTROLLER'
KAFKA_CFG_INTER_BROKER_LISTENER_NAME: 'INTERNAL'
KAFKA_CFG_LISTENERS: INTERNAL://:9094,CONTROLLER://:9093,EXTERNAL://:9092
KAFKA_CFG_LISTENER_SECURITY_PROTOCOL_MAP: CONTROLLER:PLAINTEXT,INTERNAL:PLAINTEXT,EXTERNAL:PLAINTEXT
KAFKA_CFG_ADVERTISED_LISTENERS: INTERNAL://broker2:9094,EXTERNAL://localhost:9292
KAFKA_CFG_NODE_ID: 2
KAFKA_CFG_CONTROLLER_QUORUM_VOTERS: '0@broker0:9093,1@broker1:9093,2@broker2:9093'
ALLOW_PLAINTEXT_LISTENER: yes
KAFKA_KRAFT_CLUSTER_ID: 7PnqRPczTWyvtndf7WgrYw
ports:
- "9292:9092"
volumes:
- broker2:/bitnami/kafka
kafka-ui:
container_name: kafka-ui
image: 'provectuslabs/kafka-ui:master'
depends_on:
- broker0
- broker1
- broker2
ports:
- "8092:8080"
environment:
KAFKA_CLUSTERS_0_BOOTSTRAP_SERVERS: 'broker0:9094,broker1:9094,broker2:9094'
KAFKA_CLUSTERS_0_NAME: local-kafka-cluster
DYNAMIC_CONFIG_ENABLED: 'true'
# see this, it's IMPORTANT: https://stackoverflow.com/questions/42111566/elasticsearch-in-windows-docker-image-vm-max-map-count
# and this: https://www.elastic.co/guide/en/elasticsearch/reference/current/docker.html#_windows_with_docker_desktop_wsl_2_backend
####################################################################################################################################
version: '3'
services:
opensearch-node0:
image: opensearchproject/opensearch:latest
container_name: opensearch-node0
environment:
- cluster.name=opensearch-cluster # Name the cluster
- node.name=opensearch-node0 # Name the node that will run in this container
# - node.roles=cluster_manager,remote_cluster_client
- discovery.seed_hosts=opensearch-node0,opensearch-node1,opensearch-node2 # Nodes to look for when discovering the cluster
- cluster.initial_cluster_manager_nodes=opensearch-node0,opensearch-node1,opensearch-node2 # Nodes eligible to serve as cluster manager
- bootstrap.memory_lock=true # Disable JVM heap memory swapping
- "OPENSEARCH_JAVA_OPTS=-Xms512m -Xmx512m" # Set min and max JVM heap sizes to at least 50% of system RAM
- "DISABLE_INSTALL_DEMO_CONFIG=true" # Prevents execution of bundled demo script which installs demo certificates and security configurations to OpenSearch
- "DISABLE_SECURITY_PLUGIN=true" # Disables security plugin
ulimits:
memlock:
soft: -1 # Set memlock to unlimited (no soft or hard limit)
hard: -1
nofile:
soft: 65536 # Maximum number of open files for the opensearch user - set to at least 65536
hard: 65536
volumes:
- opensearch-data0:/usr/share/opensearch/data # Creates volume called opensearch-data1 and mounts it to the container
ports:
- 9200:9200 # REST API
- 9600:9600 # Performance Analyzer
networks:
- opensearch-net # All of the containers will join the same Docker bridge network
healthcheck:
test:
[
"CMD-SHELL",
"curl --silent --fail localhost:9200/_cluster/health || exit 1"
]
opensearch-node1:
image: opensearchproject/opensearch:latest
container_name: opensearch-node1
environment:
- cluster.name=opensearch-cluster # Name the cluster
- node.name=opensearch-node1 # Name the node that will run in this container
# - node.roles=data,ingest,remote_cluster_client
- discovery.seed_hosts=opensearch-node0,opensearch-node1,opensearch-node2 # Nodes to look for when discovering the cluster
- cluster.initial_cluster_manager_nodes=opensearch-node0,opensearch-node1,opensearch-node2 # Nodes eligible to serve as cluster manager
- bootstrap.memory_lock=true # Disable JVM heap memory swapping
- "OPENSEARCH_JAVA_OPTS=-Xms512m -Xmx512m" # Set min and max JVM heap sizes to at least 50% of system RAM
- "DISABLE_INSTALL_DEMO_CONFIG=true" # Prevents execution of bundled demo script which installs demo certificates and security configurations to OpenSearch
- "DISABLE_SECURITY_PLUGIN=true" # Disables security plugin
ulimits:
memlock:
soft: -1 # Set memlock to unlimited (no soft or hard limit)
hard: -1
nofile:
soft: 65536 # Maximum number of open files for the opensearch user - set to at least 65536
hard: 65536
volumes:
- opensearch-data1:/usr/share/opensearch/data # Creates volume called opensearch-data2 and mounts it to the container
networks:
- opensearch-net # All of the containers will join the same Docker bridge network
healthcheck:
test:
[
"CMD-SHELL",
"curl --silent --fail localhost:9200/_cluster/health || exit 1"
]
opensearch-node2:
image: opensearchproject/opensearch:latest
container_name: opensearch-node2
environment:
- cluster.name=opensearch-cluster # Name the cluster
- node.name=opensearch-node2 # Name the node that will run in this container
# - node.roles=data,ingest,remote_cluster_client
- discovery.seed_hosts=opensearch-node0,opensearch-node1,opensearch-node2 # Nodes to look for when discovering the cluster
- cluster.initial_cluster_manager_nodes=opensearch-node0,opensearch-node1,opensearch-node2 # Nodes eligible to serve as cluster manager
- bootstrap.memory_lock=true # Disable JVM heap memory swapping
- "OPENSEARCH_JAVA_OPTS=-Xms512m -Xmx512m" # Set min and max JVM heap sizes to at least 50% of system RAM
- "DISABLE_INSTALL_DEMO_CONFIG=true" # Prevents execution of bundled demo script which installs demo certificates and security configurations to OpenSearch
- "DISABLE_SECURITY_PLUGIN=true" # Disables security plugin
ulimits:
memlock:
soft: -1 # Set memlock to unlimited (no soft or hard limit)
hard: -1
nofile:
soft: 65536 # Maximum number of open files for the opensearch user - set to at least 65536
hard: 65536
volumes:
- opensearch-data2:/usr/share/opensearch/data # Creates volume called opensearch-data2 and mounts it to the container
networks:
- opensearch-net # All of the containers will join the same Docker bridge network
healthcheck:
test:
[
"CMD-SHELL",
"curl --silent --fail localhost:9200/_cluster/health || exit 1"
]
opensearch-dashboards:
image: opensearchproject/opensearch-dashboards:latest
container_name: opensearch-dashboards
depends_on:
opensearch-node0:
condition: service_healthy
opensearch-node1:
condition: service_healthy
opensearch-node2:
condition: service_healthy
ports:
- 5601:5601 # Map host port 5601 to container port 5601
expose:
- "5601" # Expose port 5601 for web access to OpenSearch Dashboards
environment:
- 'OPENSEARCH_HOSTS=["http://opensearch-node0:9200","http://opensearch-node1:9200","http://opensearch-node2:9200"]'
- "DISABLE_SECURITY_DASHBOARDS_PLUGIN=true" # disables security dashboards plugin in OpenSearch Dashboards
networks:
- opensearch-net
healthcheck:
test:
[
"CMD-SHELL",
"curl --silent --fail localhost:5601 || exit 1"
]
interval: 10s
timeout: 10s
retries: 120
volumes:
opensearch-data0:
opensearch-data1:
opensearch-data2:
networks:
opensearch-net:
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment