Created
April 20, 2022 13:10
-
-
Save lucianmachado/e248e5539813a90fc44a69d1d97ab508 to your computer and use it in GitHub Desktop.
docker-compose kafka with health check
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.0" | |
services: | |
zookeeper: | |
image: confluentinc/cp-zookeeper | |
hostname: zookeeper | |
container_name: zookeeper | |
healthcheck: | |
test: nc -z localhost 2181 || exit -1 | |
interval: 10s | |
timeout: 5s | |
retries: 3 | |
ports: | |
- "2181:2181" | |
environment: | |
ZOOKEEPER_CLIENT_PORT: 2181 | |
ZOOKEEPER_TICK_TIME: 2000 | |
broker: | |
image: confluentinc/cp-kafka | |
hostname: broker | |
container_name: broker | |
depends_on: | |
- zookeeper | |
healthcheck: | |
test: kafka-topics --bootstrap-server broker:9092 --list | |
interval: 30s | |
timeout: 10s | |
retries: 3 | |
ports: | |
- "29092:29092" | |
- "9092:9092" | |
- "9101:9101" | |
environment: | |
KAFKA_BROKER_ID: 1 | |
KAFKA_ZOOKEEPER_CONNECT: 'zookeeper:2181' | |
KAFKA_LISTENER_SECURITY_PROTOCOL_MAP: PLAINTEXT:PLAINTEXT,PLAINTEXT_HOST:PLAINTEXT | |
KAFKA_ADVERTISED_LISTENERS: PLAINTEXT://broker:29092,PLAINTEXT_HOST://localhost:9092 | |
KAFKA_OFFSETS_TOPIC_REPLICATION_FACTOR: 1 | |
KAFKA_TRANSACTION_STATE_LOG_MIN_ISR: 1 | |
KAFKA_TRANSACTION_STATE_LOG_REPLICATION_FACTOR: 1 | |
KAFKA_GROUP_INITIAL_REBALANCE_DELAY_MS: 0 | |
KAFKA_JMX_PORT: 9101 | |
KAFKA_JMX_HOSTNAME: localhost | |
schema-registry: | |
image: confluentinc/cp-schema-registry | |
hostname: schema-registry | |
container_name: schema-registry | |
depends_on: | |
- broker | |
healthcheck: | |
test: curl --output /dev/null --silent --head --fail http://schema-registry:8081/subjects | |
interval: 30s | |
timeout: 10s | |
retries: 3 | |
ports: | |
- "8081:8081" | |
environment: | |
SCHEMA_REGISTRY_HOST_NAME: schema-registry | |
SCHEMA_REGISTRY_KAFKASTORE_BOOTSTRAP_SERVERS: 'broker:29092' | |
SCHEMA_REGISTRY_LISTENERS: http://0.0.0.0:8081 | |
rest-proxy: | |
image: confluentinc/cp-kafka-rest | |
depends_on: | |
- broker | |
- schema-registry | |
healthcheck: | |
test: curl --output /dev/null --silent --head --fail http://rest-proxy:8082 | |
interval: 30s | |
timeout: 10s | |
retries: 3 | |
ports: | |
- "8082:8082" | |
hostname: rest-proxy | |
container_name: rest-proxy | |
environment: | |
KAFKA_REST_HOST_NAME: rest-proxy | |
KAFKA_REST_BOOTSTRAP_SERVERS: 'broker:29092' | |
KAFKA_REST_LISTENERS: "http://0.0.0.0:8082" | |
KAFKA_REST_SCHEMA_REGISTRY_URL: 'http://schema-registry:8081' |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment