0

I have written docker-compose.yml file to create the following containers:

  • Confluent-Zookeeper
  • Confluent-Kafka
  • Confluent-Schema Registry

I want a single docker-compose file to spun up the necessary containers, expose required ports and interconnect the dependent containers. The goal is to have I am using the official confluent images from Docker Hub. My docker-compose file looks like this:

zookeeper:
  image: confluent/zookeeper
  container_name: confluent-zookeeper
  hostname: zookeeper
  environment:
    ZOOKEEPER_CLIENT_PORT: 2181
  ports:
    - "2181:2181"

kafka:
  environment:
    KAFKA_ZOOKEEPER_CONNECTION_STRING: zookeeper:2181
    KAFKA_ADVERTISED_LISTENERS: PLAINTEXT://kafka:9092
  image: confluent/kafka
  container_name: confluent-kafka
  hostname: kafka
  links:
    - zookeeper
  ports:
    - "9092:9092"

schema-registry:
  image: confluent/schema-registry
  container_name: confluent-schema_registry
  environment:
    SCHEMA_REGISTRY_KAFKASTORE_CONNECTION_URL: zookeeper:2181
    SCHEMA_REGISTRY_HOSTNAME: schema-registry
    SCHEMA_REGISTRY_LISTENERS: http://schema-registry:8081
    SCHEMA_REGISTRY_DEBUG: 'true'
    SCHEMA_REGISTRY_KAFKASTORE_TOPIC_REPLICATION_FACTOR: '1'
  links:
    - kafka
    - zookeeper
  ports:
    - "8081:8081"

Now when I run docker-compose up, all these containers will be created and launched. But Schema Registry container exits immediately. docker logs gives the following output:

 (io.confluent.kafka.schemaregistry.rest.SchemaRegistryConfig:135)
[2017-05-17 06:06:33,415] ERROR Server died unexpectedly:  (io.confluent.kafka.schemaregistry.rest.SchemaRegistryMain:51)
org.apache.kafka.common.config.ConfigException: Only plaintext and SSL Kafka endpoints are supported and none are configured.
        at io.confluent.kafka.schemaregistry.storage.KafkaStore.getBrokerEndpoints(KafkaStore.java:254)
        at io.confluent.kafka.schemaregistry.storage.KafkaStore.<init>(KafkaStore.java:111)
        at io.confluent.kafka.schemaregistry.storage.KafkaSchemaRegistry.<init>(KafkaSchemaRegistry.java:136)
        at io.confluent.kafka.schemaregistry.rest.SchemaRegistryRestApplication.setupResources(SchemaRegistryRestApplication.java:53)
        at io.confluent.kafka.schemaregistry.rest.SchemaRegistryRestApplication.setupResources(SchemaRegistryRestApplication.java:37)
        at io.confluent.rest.Application.createServer(Application.java:117)
        at io.confluent.kafka.schemaregistry.rest.SchemaRegistryMain.main(SchemaRegistryMain.java:43)

I searched for this issue but nothing helped. I tried various other configurations like providing KAFKA_ADVERTISED_HOSTNAME, changing SCHEMA_REGISTRY_LISTENERS value, etc. but no luck. Can anybody point out the exact configuration issue why Schema Registry container is failing?

OneCricketeer
  • 179,855
  • 19
  • 132
  • 245
Arman Koradia
  • 11
  • 1
  • 3

3 Answers3

1

Those are old and deprecated docker images. Use the latest supported docker images from confluentinc https://hub.docker.com/u/confluentinc/

You can find a full compose file here - confluentinc/cp-docker-images

OneCricketeer
  • 179,855
  • 19
  • 132
  • 245
Hans Jespersen
  • 8,024
  • 1
  • 24
  • 31
  • They work for me. You are missing the statement that SR "depends_on -zookeeper -kafka" – Hans Jespersen May 19 '17 at 06:03
  • schema_registry: image: confluentinc/cp-schema-registry:3.2.1 depends_on: - zookeeper - kafka ports: - '8081' environment: SCHEMA_REGISTRY_HOST_NAME: schema_registry SCHEMA_REGISTRY_KAFKASTORE_CONNECTION_URL: 'zookeeper:2181' – Hans Jespersen May 19 '17 at 06:11
  • I tried these images also. But no luck! I added `hostname: schema-registry` in docker-compose file. I landed up with new error: `SCHEMA_REGISTRY_HOST_NAME is required.` `Command [/usr/local/bin/dub ensure SCHEMA_REGISTRY_HOST_NAME] FAILED !` But this is already mentioned in docker-compose file. – Arman Koradia May 19 '17 at 06:18
  • `links` and `depends_on` does the similar function. But I just saw that in newer version docker deprecated `links`. I'll try with `depends_on`. – Arman Koradia May 19 '17 at 06:21
0

You're missing the hostname (hostname: schema-registry) entry in the failing container. By default Docker will populate a container's /etc/hosts with the linked containers' aliases and names, plus the hostname of self.

fernandezcuesta
  • 2,390
  • 1
  • 15
  • 32
0

The question is old, though it might be helpful to leave a solution that worked for me. I am using docker-compose:

version: '3.3'

services:
  zookeeper:
    image: confluent/zookeeper:3.4.6-cp1
    hostname: "zookeeper"
    networks:
      - test-net
    ports:
      - 2181:2181
    environment:
      zk_id: "1"

  kafka:
    image: confluent/kafka:0.10.0.0-cp1
    hostname: "kafka"
    depends_on:
      - zookeeper
    networks:
      - test-net
    ports:
      - 9092:9092
    environment:
      KAFKA_ADVERTISED_HOST_NAME: "kafka"
      KAFKA_ADVERTISED_LISTENERS: PLAINTEXT://kafka:9092
      KAFKA_BROKER_ID: "0"
      KAFKA_ZOOKEEPER_CONNECT: "zookeeper:2181"

  schema-registry:
    image: confluent/schema-registry:3.0.0
    hostname: "schema-registry"
    depends_on:
      - kafka
      - zookeeper
    networks:
      - test-net
    ports:
      - 8081:8081
    environment:
      SR_HOSTNAME: schema-registry
      SR_LISTENERS: http://schema-registry:8081
      SR_DEBUG: 'true'
      SR_KAFKASTORE_TOPIC_REPLICATION_FACTOR: '1'
      SR_KAFKASTORE_TOPIC_SERVERS: PLAINTEXT://kafka:9092

networks:
  test-net:
    driver: bridge`
daur88
  • 1