5

I have a Windows Subsystem Linux setup on my Windows 10 PC (Ubuntu 18.04). I installed Docker toolbox on Windows, and running through a VM I can run docker commands normally by setting:

export DOCKER_HOST=tcp://192.168.99.101:2376

I can access it fine and install/run docker containers correctly. One of these services is a Kafka Connect container running on localhost:8084, which if created from my Windows. I can access it from my Windows browser normally if I run this directly from the Ubuntu Subsystem, but if I run it from a docker container inside the Windows subsystem, I cannot access it, as if the port was not being correctly forwarded from the docker-compose file. Here is the configuration to get this service running:

#
# This docker-compose file starts and runs:
# * A 3-node kafka cluster
# * A 1-zookeeper ensemble
# * Schema Registry
# * Kafka REST Proxy
# * Kafka Connect
#

version: '3.7'

services:
  zookeeper:
    image: confluentinc/cp-zookeeper:5.2.2
    ports:
    - "2181:2181"
    environment:
      ZOOKEEPER_CLIENT_PORT: "2181"

  kafka0:
    image: confluentinc/cp-kafka:5.2.2
    ports:
    - "9092:9092"
    environment:
      KAFKA_BROKER_ID: 0
      KAFKA_ZOOKEEPER_CONNECT: "zookeeper:2181"
      KAFKA_ADVERTISED_LISTENERS: "INTERNAL://kafka0:19092,EXTERNAL://${DOCKER_HOST_IP:-127.0.0.1}:9092"
      KAFKA_INTER_BROKER_LISTENER_NAME: "INTERNAL"
      KAFKA_LISTENER_SECURITY_PROTOCOL_MAP: "INTERNAL:PLAINTEXT,EXTERNAL:PLAINTEXT"
      KAFKA_OFFSETS_TOPIC_REPLICATION_FACTOR: "1"
    depends_on:
    - "zookeeper"

  schema-registry:
    image: confluentinc/cp-schema-registry:5.2.2
    ports:
    - "8081:8081"
    environment:
      SCHEMA_REGISTRY_KAFKASTORE_BOOTSTRAP_SERVERS: "PLAINTEXT://kafka0:19092"
      SCHEMA_REGISTRY_LISTENERS: "http://0.0.0.0:8081"
      SCHEMA_REGISTRY_HOST_NAME: "schema-registry"
      SCHEMA_REGISTRY_KAFKASTORE_TOPIC_REPLICATION_FACTOR: "1"
    depends_on:
    - "kafka0"

  rest-proxy:
    image: confluentinc/cp-kafka-rest:5.2.2
    ports:
    - "8082:8082"
    environment:
      KAFKA_REST_BOOTSTRAP_SERVERS: "PLAINTEXT://kafka0:19092"
      KAFKA_REST_LISTENERS: "http://0.0.0.0:8082/"
      KAFKA_REST_HOST_NAME: "rest-proxy"
      KAFKA_REST_SCHEMA_REGISTRY_URL: "http://schema-registry:8081/"
    depends_on:
    - "kafka0"
    - "schema-registry"

  connect:
    image: confluentinc/cp-kafka-connect:5.2.2
    ports:
    - "8083:8083"
    environment:
      CONNECT_BOOTSTRAP_SERVERS: "PLAINTEXT://kafka0:19092"
      CONNECT_GROUP_ID: "connect"
      CONNECT_REST_ADVERTISED_HOST_NAME: "connect"
      CONNECT_PLUGIN_PATH: "/usr/share/java"
      CONNECT_INTERNAL_KEY_CONVERTER: "org.apache.kafka.connect.json.JsonConverter"
      CONNECT_INTERNAL_VALUE_CONVERTER: "org.apache.kafka.connect.json.JsonConverter"
      CONNECT_KEY_CONVERTER: "io.confluent.connect.avro.AvroConverter"
      CONNECT_KEY_CONVERTER_SCHEMA_REGISTRY_URL: "http://schema-registry:8081"
      CONNECT_VALUE_CONVERTER: "io.confluent.connect.avro.AvroConverter"
      CONNECT_VALUE_CONVERTER_SCHEMA_REGISTRY_URL: "http://schema-registry:8081"
      CONNECT_CONFIG_STORAGE_TOPIC: "connect-config"
      CONNECT_OFFSET_STORAGE_TOPIC: "connect-offset"
      CONNECT_STATUS_STORAGE_TOPIC: "connect-status"
      CONNECT_CONFIG_STORAGE_REPLICATION_FACTOR: "1"
      CONNECT_OFFSET_STORAGE_REPLICATION_FACTOR: "1"
      CONNECT_STATUS_STORAGE_REPLICATION_FACTOR: "1"
    depends_on:
    - "kafka0"
    - "schema-registry"

  ksql:
    image: confluentinc/cp-ksql-server:5.2.2
    ports:
    - "8088:8088"
    environment:
      KSQL_BOOTSTRAP_SERVERS: "PLAINTEXT://kafka0:19092"
      KSQL_LISTENERS: "http://0.0.0.0:8088"
      KSQL_KSQL_SERVICE_ID: "ksql_service_docker"
      KSQL_KSQL_SCHEMA_REGISTRY_URL: "http://schema-registry:8081/"
    depends_on:
    - "kafka0"
    - "schema-registry"

  connect-ui:
    image: landoop/kafka-connect-ui:0.9.7
    ports:
    - "8084:8084"
    environment:
      PORT: "8084"
      PROXY: "true"
      CONNECT_URL: "http://connect:8083"
    depends_on:
    - "connect"

  topics-ui:
    image: landoop/kafka-topics-ui:0.9.4
    ports:
    - "8085:8085"
    environment:
      PORT: "8085"
      PROXY: "true"
      KAFKA_REST_PROXY_URL: "http://rest-proxy:8082"
    depends_on:
    - "rest-proxy"

  schema-registry-ui:
    image: landoop/schema-registry-ui:0.9.5
    ports:
    - "8086:8086"
    environment:
      PORT: "8086"
      PROXY: "true"
      SCHEMAREGISTRY_URL: "http://schema-registry:8081/"
    depends_on:
    - "schema-registry"

  postgres:
    image: postgres:11
    ports:
    - "5432:5432"
    environment:
      POSTGRES_USER: "cta_admin"
      POSTGRES_PASSWORD: "chicago"
      POSTGRES_DB: "cta"
    volumes:
    - ./producers/data/cta_stations.csv:/tmp/cta_stations.csv
    - ./load_stations.sql:/docker-entrypoint-initdb.d/load_stations.sql

All other systems connect correctly and no error is logged when putting up all the docker-compose file. I have tried using different ports but no luck. Seems to me there is an issue in the binding of the docker host and the WSL host?

I would like to know:

How can I manage to connect from my Windows Chrome browser, to the service located in localhost:8084 according to the config file.

johan855
  • 1,578
  • 4
  • 26
  • 51

1 Answers1

0

Seems you didn't paste the full code of docker-compose.yml , what I guess is, your original docker-compose.yml has docker linked or networked with a kafka container named connect, so you can connect with http://connect:8003

But since kafka was installed in Windows directly (host server), the application container (kafka connect) doesn't know this host called connect

You can replace connect with your windows IP address.

  CONNECT_URL: "http://<your_windows_IP>:8083"
BMW
  • 42,880
  • 12
  • 99
  • 116
  • connect works well it seems, and the connect-ui service works well with it. I added the full docker-compose file in case you are able to see an issue. Also the issue is not the connect url but the connect-ui service not being discoverable from the browser – johan855 Apr 26 '20 at 23:40