I am using confluent kafka schema registry for avro via docker. However when I'm trying to connect to kafka it writes:
java.lang.RuntimeException: No endpoints found for security protocol [PLAINTEXT]. Endpoints found in ZK [{INTERNAL=kafka:9092, OUTSIDE=localhost:29092}]
My schema-registry:
schema-registry:
image: confluentinc/cp-schema-registry:7.3.2
environment:
- SCHEMA_REGISTRY_KAFKASTORE_CONNECTION_URL=zookeeper:2181
- SCHEMA_REGISTRY_HOST_NAME=schema-registry
- ALLOW_PLAINTEXT_LISTENER='yes'
- SCHEMA_REGISTRY_LISTENERS=http://schema-registry:8081
- SCHEMA_REGISTRY_KAFKASTORE_BOOTSTRAP_SERVERS=PLAINTEXT://kafka:29092
links:
- zookeeper
- kafka
ports:
- 8082:8081
full dockerer compose:
zookeeper:
image: confluentinc/cp-zookeeper:6.2.4
healthcheck:
test: [ "CMD", "nc", "-vz", "localhost", "2181" ]
interval: 10s
timeout: 3s
retries: 3
environment:
ZOOKEEPER_CLIENT_PORT: 2181
ZOOKEEPER_TICK_TIME: 2000
ports:
- 22181:2181
kafka:
image: confluentinc/cp-kafka:6.2.4
depends_on:
zookeeper:
condition: service_healthy
ports:
- 29092:29092
healthcheck:
test: [ "CMD", "nc", "-vz", "localhost", "9092" ]
interval: 10s
timeout: 3s
retries: 3
environment:
KAFKA_BROKER_ID: 1
KAFKA_ZOOKEEPER_CONNECT: zookeeper:2181
KAFKA_LISTENERS: OUTSIDE://:29092,INTERNAL://:9092
KAFKA_ADVERTISED_LISTENERS: OUTSIDE://localhost:29092,INTERNAL://kafka:9092
KAFKA_LISTENER_SECURITY_PROTOCOL_MAP: INTERNAL:PLAINTEXT,OUTSIDE:PLAINTEXT
KAFKA_INTER_BROKER_LISTENER_NAME: INTERNAL
KAFKA_OFFSETS_TOPIC_REPLICATION_FACTOR: 1
kafka-ui:
image: provectuslabs/kafka-ui
container_name: kafka-ui
ports:
- "8080:8080"
restart: always
depends_on:
kafka:
condition: service_healthy
environment:
KAFKA_CLUSTERS_0_NAME: local
KAFKA_CLUSTERS_0_BOOTSTRAPSERVERS: kafka:9092
service-db:
image: postgres:14.7-alpine
environment:
POSTGRES_USER: username
POSTGRES_PASSWORD: password
healthcheck:
test: ["CMD-SHELL", "pg_isready", "-d", "clients_database"]
interval: 10s
timeout: 3s
retries: 3
ports:
- "15432:5432"
volumes:
- ./infrastructure/db/create_db.sql:/docker-entrypoint-initdb.d/create_db.sql
restart: unless-stopped
pgadmin:
container_name: pgadmin_container
image: dpage/pgadmin4:7
restart: always
environment:
PGADMIN_DEFAULT_EMAIL: admin@admin.com
PGADMIN_DEFAULT_PASSWORD: root
ports:
- "5050:80"
schema-registry:
image: confluentinc/cp-schema-registry:7.3.2
environment:
- SCHEMA_REGISTRY_KAFKASTORE_CONNECTION_URL=zookeeper:2181
- SCHEMA_REGISTRY_HOST_NAME=schema-registry
- ALLOW_PLAINTEXT_LISTENER='yes'
- SCHEMA_REGISTRY_LISTENERS=http://schema-registry:8081
- SCHEMA_REGISTRY_KAFKASTORE_BOOTSTRAP_SERVERS=PLAINTEXT://kafka:29092
links:
- zookeeper
- kafka
ports:
- 8082:8081
kafka-topics-generator:
image: confluentinc/cp-kafka:6.2.4
depends_on:
kafka:
condition: service_healthy
entrypoint: [ '/bin/sh', '-c' ]
command: |
"
# blocks until kafka is reachable
kafka-topics --bootstrap-server kafka:9092 --list
echo -e 'Creating kafka topics'
kafka-topics --bootstrap-server kafka:9092 --create --if-not-exists --topic send-order-event --replication-factor 1 --partitions 2
echo -e 'Successfully created the following topics:'
kafka-topics --bootstrap-server kafka:9092 --list
"
You've set KAFKA_LISTENERS
as having INTERNAL
and OUTSIDE
Therefore, SCHEMA_REGISTRY_KAFKASTORE_BOOTSTRAP_SERVERS
should use INTERNAL
address of kafka:9092
, not PLAINTEXT
and you can remove the SCHEMA_REGISTRY_KAFKASTORE_CONNECTION_URL
variable since Zookeeper shouldn't be used and ALLOW_PLAINTEXT_LISTENER
is not a valid config for that container
You can find a fully functional Confluent Docker Compose file at https://github.com/confluentinc/cp-all-in-one/blob/7.5.0-post/cp-all-in-one/docker-compose.yml