BetterCloud / kadmin

Web Based Kafka Consumer and Producer
69 stars 25 forks source link

Connect to a kafka container #11

Open Hienphamthe opened 5 years ago

Hienphamthe commented 5 years ago

Hi guys, I followed the instruction to test kadmin with localhost, its ok. But when I tried to connect kadmin (both from executable file and docker containter) with my kafka/zookeeper container, kadmin could not establish the connection. My kafka/zookeeper container could be connected with other consumers, producers container. All of them including kadmin container are in the same network. I set the config of kadmin in docker-compose is: ZOOKEEPER_HOST: <zookeeper container IP>:<zookeeper container port> KAFKA_HOST: <kafka container IP>:<kafka container port> Could any point me out? thanks all.

OneCricketeer commented 4 years ago

You shouldn't use container IP's. You'd use service names

juanmcarballo commented 4 years ago

Should use a docker-compose file like this.

docker-compose.yml

version: '2'
services:
  zookeeper:
    image: confluentinc/cp-zookeeper:latest
    environment:
      ZOOKEEPER_CLIENT_PORT: 2181
      ZOOKEEPER_TICK_TIME: 2000

  kafka:
    image: confluentinc/cp-kafka:latest
    depends_on:
      - zookeeper
    ports:
      - 9092:9092
    environment:
      KAFKA_BROKER_ID: 1
      KAFKA_ZOOKEEPER_CONNECT: zookeeper:2181
      KAFKA_ADVERTISED_LISTENERS: PLAINTEXT://kafka:29092,PLAINTEXT_HOST://localhost:9092
      KAFKA_LISTENER_SECURITY_PROTOCOL_MAP: PLAINTEXT:PLAINTEXT,PLAINTEXT_HOST:PLAINTEXT
      KAFKA_INTER_BROKER_LISTENER_NAME: PLAINTEXT
      KAFKA_OFFSETS_TOPIC_REPLICATION_FACTOR: 1
  kadmin:
    hostname: kadmin
    image: bettercloud/kadmin
    depends_on:
      - zookeeper
      - kafka
    ports:
      - "8080:8080"
    environment:
      ZOOKEEPER_HOST: zookeeper:2181
      KAFKA_HOST: kafka:29092