You need to enable JavaScript to run this app.
优惠活动
大模型
产品
解决方案
定价
更多

Confluent Kafka REST Proxy 6.2.1版本Docker部署启动失败:LOG4J错误、环境变量未生效及SLF4J多绑定问题解决请求

Fixing Kafka REST Proxy 6.2.1 Docker Deployment Issues with Docker Compose Env Vars

I’ve worked through similar headaches with Confluent Platform 6.x, so let’s tackle each problem step by step using only environment variables in your docker-compose file—no external config files required.

1. Fix Core Startup Failure (Empty Configs & Missing Bootstrap Servers)

First off, your KAFKA_REST_BOOTSTRAP_SERVERS has a typo: 192.168.100:14:9092 should be 192.168.100.14:9092. That’s why bootstrap.servers was showing up empty in KafkaRestConfig.

Also, Confluent 6.2.x recommends using bootstrap.servers over zookeeper.connect for Kafka REST Proxy (zookeeper-based config is deprecated for newer versions). Here’s the corrected base config:

environment:
  KAFKA_REST_HOST_NAME: kafka-rest-1
  KAFKA_REST_LISTENERS: http://0.0.0.0:8082
  KAFKA_REST_BOOTSTRAP_SERVERS: 192.168.100.14:9092
  # Uncomment if using Schema Registry
  # KAFKA_REST_SCHEMA_REGISTRY_URL: http://192.168.100.14:8081

2. Resolve SLF4J Multiple Bindings Warning

The warning pops up because two SLF4J binding jars are present in the classpath. We can force the container to use only the log4j12 binding (which matches Confluent’s default logging setup) by overriding the CLASSPATH environment variable:

Add this to your environment block:

CLASSPATH: "/usr/share/java/kafka-rest/slf4j-log4j12-1.7.30.jar:/usr/share/java/kafka-rest/*"

This prioritizes the log4j12 binding and excludes the simple binding jar from being loaded.

3. Fix Log4J Initialization & Permission Denied Errors

Permission Issue

The /kafka-rest.log permission error happens because the default container user doesn’t have write access to the root directory. Instead of fighting permissions, configure Log4J to output logs directly to stdout (standard practice for Docker containers):

Log4J Configuration

Add these environment variables to set up a console appender and avoid file-based logging:

KAFKA_REST_LOG4J_ROOT_LOGLEVEL: "INFO"
KAFKA_REST_LOG4J_APPENDER_STDOUT: "org.apache.log4j.ConsoleAppender"
KAFKA_REST_LOG4J_APPENDER_STDOUT_LAYOUT: "org.apache.log4j.PatternLayout"
KAFKA_REST_LOG4J_APPENDER_STDOUT_LAYOUT_CONVERSIONPATTERN: "%d{ISO8601} %p %c{1}: %m%n"
KAFKA_REST_LOG4J_LOGGERS: "org.apache.zookeeper=ERROR,org.I0Itec.zkclient=ERROR,org.reflections=ERROR"

This eliminates the need for writing to a file, fixes the "no appender found" warning, and cleans up noisy debug logs from dependencies.

4. SLF4J Warnings When Using Schema Registry

The same CLASSPATH override above will resolve this, as it ensures the log4j12 binding is used across all components loaded by the Kafka REST Proxy container—including Schema Registry client libraries.

Final Working Docker Compose Snippet

Putting it all together, your kafka-rest-1 service should look like this:

kafka-rest-1:
  image: confluentinc/cp-kafka-rest:6.2.1
  hostname: kafka-rest-1
  container_name: kafka-rest-1
  depends_on:
    - zookeeper-1
    - broker-1
  ports:
    - "8082:8082"
  environment:
    KAFKA_REST_HOST_NAME: kafka-rest-1
    KAFKA_REST_LISTENERS: http://0.0.0.0:8082
    KAFKA_REST_BOOTSTRAP_SERVERS: 192.168.100.14:9092
    # Uncomment if using Schema Registry
    # KAFKA_REST_SCHEMA_REGISTRY_URL: http://192.168.100.14:8081
    CLASSPATH: "/usr/share/java/kafka-rest/slf4j-log4j12-1.7.30.jar:/usr/share/java/kafka-rest/*"
    KAFKA_REST_LOG4J_ROOT_LOGLEVEL: "INFO"
    KAFKA_REST_LOG4J_APPENDER_STDOUT: "org.apache.log4j.ConsoleAppender"
    KAFKA_REST_LOG4J_APPENDER_STDOUT_LAYOUT: "org.apache.log4j.PatternLayout"
    KAFKA_REST_LOG4J_APPENDER_STDOUT_LAYOUT_CONVERSIONPATTERN: "%d{ISO8601} %p %c{1}: %m%n"
    KAFKA_REST_LOG4J_LOGGERS: "org.apache.zookeeper=ERROR,org.I0Itec.zkclient=ERROR,org.reflections=ERROR"
  networks:
    - mynet

Why This Works for 6.2.1 vs 6.0.0

Confluent made minor tweaks to classpath ordering and logging defaults between 6.0.0 and 6.2.1. The 6.0.0 image likely had a cleaner classpath by default, while 6.2.1 includes both SLF4J bindings. Our CLASSPATH override forces the correct binding, and the Log4J env vars align with the newer image’s logging expectations.

内容的提问来源于stack exchange,提问作者Alex Pristenskiy

相关产品推荐
方舟 Agent Plan

超全模态模型 × Harness 升级,最新支持 Deepseek-V4.1-Flash、GLM-5.3 系列、Doubao-Seedream-5.0-pro、Kimi-K3 (部分), 限时 9.9 元起

最近更新时间:2026.04.30 18:58:14