skip to Main Content

to set the context, i have a very basic kafka server setup through a docker-compose.yml file, and then i spin up a ui app for kafka.

depending on the config, the ui app will/wont work becuase of port 8080 being used/free.

my question is how does 8080 tie into this, when the difference between working and non working configs is the host ip.

btw this is done in wsl (with the wsl ip being the ip in question 172.20.123.69.)

ui app:

podman run 
    --name kafka_ui 
    -p 8080:8080 
    -e KAFKA_CLUSTERS_0_NAME=local 
    -e KAFKA_CLUSTERS_0_BOOTSTRAPSERVERS=172.20.123.69:9092 
    -d provectuslabs/kafka-ui:latest

ui works with this kafka server config:

version: "2"

services:
  zookeeper:
    container_name: zookeeper-server
    image: docker.io/bitnami/zookeeper:3.8
    ports:
      - "2181:2181"
    volumes:
      - "/home/rndom/volumes/zookeeper:/bitnami/zookeeper"
    environment:
      - ALLOW_ANONYMOUS_LOGIN=yes
  kafka:
    container_name: kafka-server
    image: docker.io/bitnami/kafka:3.3
    ports:
      - "9092:9092"
    volumes:
      - "/home/rndom/volumes/kafka:/bitnami/kafka"
    environment:
      - KAFKA_BROKER_ID=1
      - KAFKA_CFG_LISTENERS=PLAINTEXT://:9092
      - KAFKA_CFG_ADVERTISED_LISTENERS=PLAINTEXT://172.20.123.69:9092
      - KAFKA_CFG_ZOOKEEPER_CONNECT=zookeeper:2181
      - ALLOW_PLAINTEXT_LISTENER=yes
    depends_on:
      - zookeeper

volumes:
  zookeeper_data:
    driver: bridge
  kafka_data:
    driver: bridge

networks:
  downloads_default:
    driver: bridge

notice the environment variable KAFKA_CFG_ADVERTISED_LISTENERS has the wsl ip.

ui doesn’t work with the following:

version: "2"

services:
  zookeeper:
    container_name: zookeeper-server
    image: docker.io/bitnami/zookeeper:3.8
    ports:
      - "2181:2181"
    volumes:
      - "/home/rndom/volumes/zookeeper:/bitnami/zookeeper"
    environment:
      - ALLOW_ANONYMOUS_LOGIN=yes
  kafka:
    container_name: kafka-server
    image: docker.io/bitnami/kafka:3.3
    ports:
      - "9092:9092"
    volumes:
      - "/home/rndom/volumes/kafka:/bitnami/kafka"
    environment:
      - KAFKA_BROKER_ID=1
      - KAFKA_CFG_LISTENERS=PLAINTEXT://:9092
      - KAFKA_CFG_ADVERTISED_LISTENERS=PLAINTEXT://:9092
      - KAFKA_CFG_ZOOKEEPER_CONNECT=zookeeper:2181
      - ALLOW_PLAINTEXT_LISTENER=yes
    depends_on:
      - zookeeper

volumes:
  zookeeper_data:
    driver: bridge
  kafka_data:
    driver: bridge

networks:
  downloads_default:
    driver: bridge

the latter i got from the official bitnami docker hub repo.

the error i get when i use it:

*************************
APPLICATION FAILED TO START
*************************
etc etc.

Web server failed to start Port 8080 was already in use

Since i got it to work, this is really just for my own understanding.

2

Answers


  1. try the command "netstat -tupan" and check if 8080 is not used by any other process.

    Login or Signup to reply.
    • Do use KAFKA_CFG_ADVERTISED_LISTENERS=PLAINTEXT://kafka:9092

    • Don’t use podman run for one container. Put the UI container in the same compose file

    • Use KAFKA_CLUSTERS_0_BOOTSTRAPSERVERS=kafka:9092


    If you still get errors, then as the error says, the port is occupied, so use a different one like 8081:8080. That has nothing to do with the Kafka setup.


    This Compose file works fine for me

    version: "2"
    
    services:
      zookeeper:
        image: docker.io/bitnami/zookeeper:3.8
        environment:
          - ALLOW_ANONYMOUS_LOGIN=yes
      kafka:
        image: docker.io/bitnami/kafka:3.3
        environment:
          - KAFKA_BROKER_ID=1
          - KAFKA_CFG_LISTENERS=PLAINTEXT://0.0.0.0:9092
          - KAFKA_CFG_ADVERTISED_LISTENERS=PLAINTEXT://kafka:9092
          - KAFKA_CFG_ZOOKEEPER_CONNECT=zookeeper:2181
          - ALLOW_PLAINTEXT_LISTENER=yes
        depends_on:
          - zookeeper
    
      kafka_ui:
        image: docker.io/provectuslabs/kafka-ui:latest
        ports:
          - 8080:8080
        environment:
          - KAFKA_CLUSTERS_0_NAME=local
          - KAFKA_CLUSTERS_0_BOOTSTRAPSERVERS=kafka:9092
    
    Login or Signup to reply.
Please signup or login to give your own answer.
Back To Top
Search