--- version: '3.9' #### NETWORKS networks: docker-traefik_front_network: external: true back_network: driver: bridge attachable: true #### SERVICES services: ### zookeeper-kafka zookeeper-kafka: container_name: zookeeper hostname: zookeeper image: confluentinc/cp-zookeeper:latest ports: - '2181:2181' networks: - back_network environment: ZOOKEEPER_CLIENT_PORT: 2181 ZOOKEEPER_TICK_TIME: 2000 healthcheck: # fake healthcheck just to have one to simplify status check test: ['CMD', 'date'] interval: 10s timeout: 5s retries: 5 ### kafka ### docs at: https://registry.hub.docker.com/r/wurstmeister/kafka kafka: container_name: kafka hostname: kafka image: wurstmeister/kafka:latest restart: always depends_on: - zookeeper-kafka ports: - '9092:9092' networks: - back_network volumes: # It's the only way to deal with Kafka non-static exposed ports to host # See: https://github.com/wurstmeister/kafka-docker/blob/master/start-kafka.sh#L65-L76 - /var/run/docker.sock:/var/run/docker.sock environment: KAFKA_BROKER_ID: 1 KAFKA_ZOOKEEPER_CONNECT: 'zookeeper-kafka:2181' PORT_COMMAND: 'docker port $$(hostname) 9092/tcp | cut -d: -f2' KAFKA_LISTENERS: 'LISTENER_INTERNAL://kafka:29092,LISTENER_HOST://:9092' KAFKA_ADVERTISED_LISTENERS: LISTENER_INTERNAL://kafka:29092,LISTENER_HOST://localhost:_{PORT_COMMAND} KAFKA_LISTENER_SECURITY_PROTOCOL_MAP: LISTENER_INTERNAL:PLAINTEXT,LISTENER_HOST:PLAINTEXT KAFKA_INTER_BROKER_LISTENER_NAME: LISTENER_INTERNAL KAFKA_AUTO_CREATE_TOPICS_ENABLE: 'true' KAFKA_CREATE_TOPICS: 'test:1:1' healthcheck: test: [ 'CMD', '/opt/kafka/bin/kafka-topics.sh', '--list', '--bootstrap-server', 'kafka:29092', ] interval: 10s timeout: 5s retries: 5 ### kafka-ui kafka-ui: container_name: kafka-ui hostname: kafka-ui image: provectuslabs/kafka-ui:latest # ports: # - "8080:8080" networks: - docker-traefik_front_network - back_network depends_on: - zookeeper-kafka - kafka environment: KAFKA_CLUSTERS_0_NAME: local KAFKA_CLUSTERS_0_BOOTSTRAPSERVERS: kafka:29092 KAFKA_CLUSTERS_0_ZOOKEEPER: zookeeper-kafka:2181 KAFKA_CLUSTERS_0_JMXPORT: 9997 labels: - "traefik.enable=true" - "traefik.docker.network=docker-traefik_front_network" # HTTP - "traefik.http.routers.kafka-http.rule=Host(`kafka-ui.10.0.4.29.traefik.me`)" - "traefik.http.routers.kafka-http.entrypoints=http" # HTTPS - "traefik.http.routers.kafka-https.rule=Host(`kafka-ui.10.0.4.29.traefik.me`)" - "traefik.http.routers.kafka-https.entrypoints=https" - "traefik.http.routers.kafka-https.service=kafka-service" - "traefik.http.routers.kafka-https.tls=true" # Middleware # Service - "traefik.http.services.kafka-service.loadbalancer.server.port=8080"