Last active
March 9, 2022 12:42
-
-
Save piotrpersona/2ce0ad8c0aca357408f46ddeeb04d39a to your computer and use it in GitHub Desktop.
kafka docker-compose setup
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
version: "3.9" | |
services: | |
example-app: | |
image: example-app | |
environment: | |
KAFKA_BOOTSTRAP_SERVERS: "kafka:19092". # this setting is important: LISTENER_DOCKER_INTERNAL://kafka:19092 | |
KAFKA_TOPIC: "topic-name" | |
KAFKA_SCHEMA_REGISTRY_URL: "http://kafka-schema-registry:8081" | |
ports: | |
- "8002:8002" | |
links: | |
- kafka | |
- kafka-schema-registry | |
depends_on: | |
- kafka | |
- kafka-schema-registry | |
zookeeper: | |
image: confluentinc/cp-zookeeper:6.2.1 | |
restart: always | |
hostname: zookeeper | |
container_name: zookeeper | |
ports: | |
- "2181:2181" | |
environment: | |
ZOOKEEPER_CLIENT_PORT: 2181 | |
ZOOKEEPER_SERVER_ID: 1 | |
ZOOKEEPER_SERVERS: zookeeper:2888:3888 | |
volumes: | |
- zookeeper-data:/data | |
- zookeeper-log:/datalog | |
kafka: | |
image: confluentinc/cp-kafka:6.2.1 | |
restart: always | |
hostname: kafka | |
container_name: kafka | |
user: "appuser:appuser" | |
ports: | |
- "9092:9092" | |
- "9999:9999" | |
- "19092:19092" | |
environment: | |
KAFKA_ADVERTISED_LISTENERS: LISTENER_DOCKER_INTERNAL://kafka:19092,LISTENER_DOCKER_EXTERNAL://${DOCKER_HOST_IP:-127.0.0.1}:9092 | |
KAFKA_LISTENER_SECURITY_PROTOCOL_MAP: LISTENER_DOCKER_INTERNAL:PLAINTEXT,LISTENER_DOCKER_EXTERNAL:PLAINTEXT | |
KAFKA_INTER_BROKER_LISTENER_NAME: LISTENER_DOCKER_INTERNAL | |
KAFKA_ZOOKEEPER_CONNECT: "zookeeper:2181" | |
KAFKA_BROKER_ID: 1 | |
KAFKA_LOG4J_LOGGERS: "kafka.controller=INFO,kafka.producer.async.DefaultEventHandler=INFO,state.change.logger=INFO" | |
KAFKA_OFFSETS_TOPIC_REPLICATION_FACTOR: 1 | |
KAFKA_TRANSACTION_STATE_LOG_REPLICATION_FACTOR: 1 | |
KAFKA_TRANSACTION_STATE_LOG_MIN_ISR: 1 | |
KAFKA_JMX_PORT: 9999 | |
KAFKA_JMX_HOSTNAME: ${DOCKER_HOST_IP:-127.0.0.1} | |
volumes: | |
- kafka-data:/var/lib/kafka/data | |
depends_on: | |
- zookeeper | |
kafka-schema-registry: | |
image: confluentinc/cp-schema-registry:6.2.1 | |
container_name: kafka-schema-registry | |
hostname: kafka-schema-registry | |
depends_on: | |
- zookeeper | |
- kafka | |
ports: | |
- "8081:8081" | |
environment: | |
SCHEMA_REGISTRY_HOST_NAME: kafka-schema-registry | |
SCHEMA_REGISTRY_KAFKASTORE_BOOTSTRAP_SERVERS: 'PLAINTEXT://rounds-kafka:19092' | |
SCHEMA_REGISTRY_LISTENERS: http://0.0.0.0:8081 | |
volumes: | |
zookeeper-data: | |
zookeeper-log: | |
kafka-data: |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment