Docker with zookeeper kafka and kafka ui

I’m getting this error on zookeeper

2024-09-06 12:46:07 [2024-09-06 15:46:07,990] ERROR cnxn.saslServer is null: cnxn object did not initialize its saslServer properly. (org.apache.zookeeper.server.ZooKeeperServer)
2024-09-06 12:46:08 [2024-09-06 15:46:08,383] WARN Unable to read additional data from client sessionid 0x100005f45720000, likely client has closed socket (org.apache.zookeeper.server.NIOServerCnxn)
2024-09-06 12:46:49 [2024-09-06 15:46:49,536] INFO Expiring session 0x100005f45720000, timeout of 40000ms exceeded (org.apache.zookeeper.server.ZooKeeperServer)

I’m getting this error on kafka

NFO SASL config status: Will attempt to SASL-authenticate using Login Context section 'Client' (org.apache.zookeeper.ClientCnxn)
2024-09-06 12:46:05 [2024-09-06 15:46:05,744] WARN Session 0x0 for server zookeeper/172.18.0.2:2181, Closing socket connection. Attempting reconnect except it is a SessionExpiredException. (org.apache.zookeeper.ClientCnxn)
2024-09-06 12:46:05 java.net.ConnectException: Connection refused
2024-09-06 12:46:05     at java.base/sun.nio.ch.Net.pollConnect(Native Method)
2024-09-06 12:46:05     at java.base/sun.nio.ch.Net.pollConnectNow(Net.java:672)
2024-09-06 12:46:05     at java.base/sun.nio.ch.SocketChannelImpl.finishConnect(SocketChannelImpl.java:946)
2024-09-06 12:46:05     at org.apache.zookeeper.ClientCnxnSocketNIO.doTransport(ClientCnxnSocketNIO.java:344)
2024-09-06 12:46:05     at org.apache.zookeeper.ClientCnxn$SendThread.run(ClientCnxn.java:1289)
2024-09-06 12:46:06 [2024-09-06 15:46:06,848] INFO Client will use DIGEST-MD5 as SASL mechanism. (org.apache.zookeeper.client.ZooKeeperSaslClient)
2024-09-06 12:46:06 [2024-09-06 15:46:06,848] INFO Opening socket connection to server zookeeper/172.18.0.2:2181. (org.apache.zookeeper.ClientCnxn)
2024-09-06 12:46:06 [2024-09-06 15:46:06,848] INFO SASL config status: Will attempt to SASL-authenticate using Login Context section 'Client' (org.apache.zookeeper.ClientCnxn)
2024-09-06 12:46:06 [2024-09-06 15:46:06,849] WARN Session 0x0 for server zookeeper/172.18.0.2:2181, Closing socket connection. Attempting reconnect except it is a SessionExpiredException. (org.apache.zookeeper.ClientCnxn)
2024-09-06 12:46:06 java.net.ConnectException: Connection refused
2024-09-06 12:46:06     at java.base/sun.nio.ch.Net.pollConnect(Native Method)
2024-09-06 12:46:06     at java.base/sun.nio.ch.Net.pollConnectNow(Net.java:672)
2024-09-06 12:46:06     at java.base/sun.nio.ch.SocketChannelImpl.finishConnect(SocketChannelImpl.java:946)
2024-09-06 12:46:06     at org.apache.zookeeper.ClientCnxnSocketNIO.doTransport(ClientCnxnSocketNIO.java:344)
2024-09-06 12:46:06     at org.apache.zookeeper.ClientCnxn$SendThread.run(ClientCnxn.java:1289)
2024-09-06 12:46:07 [2024-09-06 15:46:07,957] INFO Client will use DIGEST-MD5 as SASL mechanism. (org.apache.zookeeper.client.ZooKeeperSaslClient)
2024-09-06 12:46:07 [2024-09-06 15:46:07,957] INFO Opening socket connection to server zookeeper/172.18.0.2:2181. (org.apache.zookeeper.ClientCnxn)
2024-09-06 12:46:07 [2024-09-06 15:46:07,957] INFO SASL config status: Will attempt to SASL-authenticate using Login Context section 'Client' (org.apache.zookeeper.ClientCnxn)
2024-09-06 12:46:07 [2024-09-06 15:46:07,957] INFO Socket connection established, initiating session, client: /172.18.0.3:51600, server: zookeeper/172.18.0.2:2181 (org.apache.zookeeper.ClientCnxn)
2024-09-06 12:46:07 [2024-09-06 15:46:07,987] INFO Session establishment complete on server zookeeper/172.18.0.2:2181, session id = 0x100005f45720000, negotiated timeout = 40000 (org.apache.zookeeper.ClientCnxn)
2024-09-06 12:46:07 [2024-09-06 15:46:07,991] ERROR SASL authentication failed using login context 'Client'. (org.apache.zookeeper.client.ZooKeeperSaslClient)
2024-09-06 12:46:07 javax.security.sasl.SaslException: Error in authenticating with a Zookeeper Quorum member: the quorum member's saslToken is null.
2024-09-06 12:46:07     at org.apache.zookeeper.client.ZooKeeperSaslClient.createSaslToken(ZooKeeperSaslClient.java:310)
2024-09-06 12:46:07     at org.apache.zookeeper.client.ZooKeeperSaslClient.respondToServer(ZooKeeperSaslClient.java:270)
2024-09-06 12:46:07     at org.apache.zookeeper.ClientCnxn$SendThread.readResponse(ClientCnxn.java:936)
2024-09-06 12:46:07     at org.apache.zookeeper.ClientCnxnSocketNIO.doIO(ClientCnxnSocketNIO.java:98)
2024-09-06 12:46:07     at org.apache.zookeeper.ClientCnxnSocketNIO.doTransport(ClientCnxnSocketNIO.java:350)
2024-09-06 12:46:07     at org.apache.zookeeper.ClientCnxn$SendThread.run(ClientCnxn.java:1289)
2024-09-06 12:46:07 [2024-09-06 15:46:07,991] INFO EventThread shut down for session: 0x100005f45720000 (org.apache.zookeeper.ClientCnxn)
2024-09-06 12:46:07 [2024-09-06 15:46:07,991] ERROR Error occurred while connecting to Zookeeper server[zookeeper:2181]. Authentication failed.  (io.confluent.admin.utils.ClusterStatus)
2024-09-06 12:46:08 Using log4j config /etc/kafka/log4j.properties

Follow my code:

docker-compose.yml
services:
  zookeeper:
    image: confluentinc/cp-zookeeper:6.1.4
    environment:
      ZOOKEEPER_CLIENT_PORT: 2181
      ZOOKEEPER_TICK_TIME: 2000
      ZOOKEEPER_QUORUM_LISTEN_ON_ALL_IPS: 'true'
      ZOOKEEPER_SASL_ENABLED: "true"
      JVMFLAGS: "-Djava.security.auth.login.config=/etc/zookeeper/zookeeper_jaas.conf"
    volumes:
      - ./zookeeper_jaas.conf:/etc/zookeeper/zookeeper_jaas.conf
    ports:
      - "2181:2181"

  kafka:
    image: confluentinc/cp-kafka:latest
    depends_on:
      - zookeeper
    ports:
      - "9092:9092"
      - "9093:9093"  # SASL/PLAIN port
    environment:
      KAFKA_BROKER_ID: 1
      KAFKA_ZOOKEEPER_CONNECT: zookeeper:2181
      KAFKA_ZOOKEEPER_SET_ACL: true
      KAFKA_ADVERTISED_LISTENERS: PLAINTEXT://localhost:9092, SASL_PLAINTEXT://localhost:9093
      KAFKA_LISTENER_SECURITY_PROTOCOL_MAP: PLAINTEXT:PLAINTEXT, SASL_PLAINTEXT:SASL_PLAINTEXT
      KAFKA_INTER_BROKER_LISTENER_NAME: SASL_PLAINTEXT
      KAFKA_SASL_ENABLED_MECHANISMS: PLAIN
      KAFKA_SASL_MECHANISM_INTER_BROKER_PROTOCOL: PLAIN
      KAFKA_OPTS: "-Djava.security.auth.login.config=/etc/kafka/kafka_server_jaas.conf"
    volumes:
      - ./kafka_server_jaas.conf:/etc/kafka/kafka_server_jaas.conf

  kafka-ui:
    image: provectuslabs/kafka-ui:latest
    depends_on:
      - kafka
    ports:
      - "8080:8080"
    environment:
      KAFKA_CLUSTERS_0_NAME: local
      KAFKA_CLUSTERS_0_BOOTSTRAPSERVERS: kafka:9093
      KAFKA_CLUSTERS_0_PROPERTIES_SECURITY_PROTOCOL: SASL_PLAINTEXT
      KAFKA_CLUSTERS_0_PROPERTIES_SASL_MECHANISM: PLAIN
      KAFKA_CLUSTERS_0_PROPERTIES_SASL_JAAS_CONFIG: "org.apache.kafka.common.security.plain.PlainLoginModule required username='admin' password='admin-secret';"

kafka_server_jaas.conf
KafkaServer {
   org.apache.kafka.common.security.plain.PlainLoginModule required
   username="admin"
   password="admin-secret"
   user_admin="admin-secret"
   user_user="user-secret";
};

Client {
   org.apache.zookeeper.server.auth.DigestLoginModule required
   username="kafka"
   password="kafka-secret";
};
Server {
   org.apache.zookeeper.server.auth.DigestLoginModule required
   user_kafka="kafka-secret";
};
zookeeper_jaas.conf
Server {
   org.apache.zookeeper.server.auth.DigestLoginModule required
   user_kafka="kafka-secret";
};

I need assistance with configuring a Docker image using docker-compose where I’m implementing SASL authentication. Specifically, I’m encountering issues during the setup process. The problem seems to be related to integrating SASL authentication correctly with the Docker containers. Can someone guide me through the steps to resolve this issue or provide insight into common pitfalls when using SASL authentication in a Docker environment?

1

Trang chủ Giới thiệu Sinh nhật bé trai Sinh nhật bé gái Tổ chức sự kiện Biểu diễn giải trí Dịch vụ khác Trang trí tiệc cưới Tổ chức khai trương Tư vấn dịch vụ Thư viện ảnh Tin tức - sự kiện Liên hệ Chú hề sinh nhật Trang trí YEAR END PARTY công ty Trang trí tất niên cuối năm Trang trí tất niên xu hướng mới nhất Trang trí sinh nhật bé trai Hải Đăng Trang trí sinh nhật bé Khánh Vân Trang trí sinh nhật Bích Ngân Trang trí sinh nhật bé Thanh Trang Thuê ông già Noel phát quà Biểu diễn xiếc khỉ Xiếc quay đĩa Dịch vụ tổ chức sự kiện 5 sao Thông tin về chúng tôi Dịch vụ sinh nhật bé trai Dịch vụ sinh nhật bé gái Sự kiện trọn gói Các tiết mục giải trí Dịch vụ bổ trợ Tiệc cưới sang trọng Dịch vụ khai trương Tư vấn tổ chức sự kiện Hình ảnh sự kiện Cập nhật tin tức Liên hệ ngay Thuê chú hề chuyên nghiệp Tiệc tất niên cho công ty Trang trí tiệc cuối năm Tiệc tất niên độc đáo Sinh nhật bé Hải Đăng Sinh nhật đáng yêu bé Khánh Vân Sinh nhật sang trọng Bích Ngân Tiệc sinh nhật bé Thanh Trang Dịch vụ ông già Noel Xiếc thú vui nhộn Biểu diễn xiếc quay đĩa Dịch vụ tổ chức tiệc uy tín Khám phá dịch vụ của chúng tôi Tiệc sinh nhật cho bé trai Trang trí tiệc cho bé gái Gói sự kiện chuyên nghiệp Chương trình giải trí hấp dẫn Dịch vụ hỗ trợ sự kiện Trang trí tiệc cưới đẹp Khởi đầu thành công với khai trương Chuyên gia tư vấn sự kiện Xem ảnh các sự kiện đẹp Tin mới về sự kiện Kết nối với đội ngũ chuyên gia Chú hề vui nhộn cho tiệc sinh nhật Ý tưởng tiệc cuối năm Tất niên độc đáo Trang trí tiệc hiện đại Tổ chức sinh nhật cho Hải Đăng Sinh nhật độc quyền Khánh Vân Phong cách tiệc Bích Ngân Trang trí tiệc bé Thanh Trang Thuê dịch vụ ông già Noel chuyên nghiệp Xem xiếc khỉ đặc sắc Xiếc quay đĩa thú vị
Trang chủ Giới thiệu Sinh nhật bé trai Sinh nhật bé gái Tổ chức sự kiện Biểu diễn giải trí Dịch vụ khác Trang trí tiệc cưới Tổ chức khai trương Tư vấn dịch vụ Thư viện ảnh Tin tức - sự kiện Liên hệ Chú hề sinh nhật Trang trí YEAR END PARTY công ty Trang trí tất niên cuối năm Trang trí tất niên xu hướng mới nhất Trang trí sinh nhật bé trai Hải Đăng Trang trí sinh nhật bé Khánh Vân Trang trí sinh nhật Bích Ngân Trang trí sinh nhật bé Thanh Trang Thuê ông già Noel phát quà Biểu diễn xiếc khỉ Xiếc quay đĩa
Thiết kế website Thiết kế website Thiết kế website Cách kháng tài khoản quảng cáo Mua bán Fanpage Facebook Dịch vụ SEO Tổ chức sinh nhật