Created
July 15, 2023 22:40
-
-
Save luismir15/95a831592cff9fcf7d710b8a3dd27f14 to your computer and use it in GitHub Desktop.
Docker compose file for Kafka
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: '2.1' | |
networks: | |
app-tier: | |
driver: bridge | |
services: | |
zookeeper: | |
image: 'bitnami/zookeeper:3' | |
container_name: zookeeper | |
ports: | |
- '2181:2181' | |
environment: | |
- ALLOW_ANONYMOUS_LOGIN=yes | |
networks: | |
- app-tier | |
kafka: | |
image: 'bitnami/kafka:2' | |
container_name: kafkaContainer | |
ports: | |
- '9092:9092' | |
environment: | |
- KAFKA_CFG_ZOOKEEPER_CONNECT=zookeeper:2181 | |
- ALLOW_PLAINTEXT_LISTENER=yes | |
- KAFKA_CFG_LISTENER_SECURITY_PROTOCOL_MAP=PLAINTEXT:PLAINTEXT,PLAINTEXT_HOST:PLAINTEXT | |
- KAFKA_CFG_LISTENERS=PLAINTEXT://kafkaContainer:29092,PLAINTEXT_HOST://kafkaContainer:9092 | |
- KAFKA_CFG_ADVERTISED_LISTENERS=PLAINTEXT://kafkaContainer:29092,PLAINTEXT_HOST://localhost:9092 | |
- KAFKA_CFG_INTER_BROKER_LISTENER_NAME=PLAINTEXT | |
- KAFKA_CFG_AUTO_CREATE_TOPICS_ENABLE=true | |
depends_on: | |
- "zookeeper" | |
links: | |
- zookeeper | |
healthcheck: | |
test: | |
["CMD", "kafka-topics.sh", "--list", "--zookeeper", "zookeeper:2181"] | |
interval: 30s | |
timeout: 10s | |
retries: 4 | |
networks: | |
- app-tier | |
db: | |
image: mysql:5.7 | |
restart: always | |
environment: | |
MYSQL_DATABASE: 'db' | |
# So you don't have to use root, but you can if you like | |
MYSQL_USER: 'user' | |
# You can use whatever password you like | |
MYSQL_PASSWORD: 'user123' | |
# Password for root access | |
MYSQL_ROOT_PASSWORD: 'user123' | |
ports: | |
# <Port exposed> : < MySQL Port running inside container> | |
- '3306:3306' | |
expose: | |
# Opens port 3306 on the container | |
- '3306' | |
# Where our data will be persisted | |
volumes: | |
- my-db:/var/lib/mysql | |
depends_on: | |
- "kafka" | |
links: | |
- kafka | |
# Names our volume | |
volumes: | |
my-db: |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment