Search code examples
dockerdocker-swarmdocker-machinedocker-network

Why can't my service commmunicate with the other services in the overlay network of my Docker swarm?


I'm having trouble communicating with my schema-registry and kafka-rest services from the other containers in the overlay network within my swarm.

After provisioning my nodes and joining them to the swarm, I created an overlay network using this command:

docker network create -d overlay --attachable kafka-net

I created each service using these commands:

https://gist.github.com/jhines2k7/4c9e8d4c2c6ac60a076072cc28fad998

The service is running properly. Here's the log output from the schema-registry service:

https://gist.github.com/jhines2k7/39d6c6bc3dea5d1065718e87d7e3710a

All services in the swarm are running properly:

https://gist.github.com/jhines2k7/dc2ca41ebbf09c9fdf08e6527b72418a

I'm able to communicate with other containers in the network:

https://gist.github.com/jhines2k7/c746008e9da79f8e69a668751acfa602

All commands were run on a DigitalOcean Droplet running Ubuntu 17.10 Docker version 17.12.0-ce docker-machine version 0.14.0


Solution

  • I was able to resolve this issue by providing the proper value for the SCHEMA_REGISTRY_LISTENERS env variable. Before, my command to create the schema-registry service looked like this:

    docker service create \
    --network=kafka-net \
    --name=schema-registry \
    -e SCHEMA_REGISTRY_KAFKASTORE_CONNECTION_URL=zk1:22181 \
    -e SCHEMA_REGISTRY_HOST_NAME=schema-registry \
    -e SCHEMA_REGISTRY_LISTENERS=http://schema-registry:8081 \
    --constraint "engine.labels.node.type==webtools" \
    confluentinc/cp-schema-registry:4.0.0
    

    Notice the value for the SCHEMA_REGISTRY_LISTENERS environment variable. After changing the value from http://schema-registry:8081 to http://0.0.0.0:8081...

    docker service create \
    --network=kafka-net \
    --name=schema-registry \
    -e SCHEMA_REGISTRY_KAFKASTORE_CONNECTION_URL=zk1:22181 \
    -e SCHEMA_REGISTRY_HOST_NAME=schema-registry \
    -e SCHEMA_REGISTRY_LISTENERS=http://0.0.0.0:8081 \
    --constraint "engine.labels.node.type==webtools" \
    confluentinc/cp-schema-registry:4.0.0
    

    My schema-registry service was able to communicate with the other services in the swarm.