Hostname/IP of Docker Host server in Swarm mode

The container could not know its’ host’s ip in the swarm mode. The only way that container could know the host’s ip is using the “host” network mode. While, Swarm requires the service to use the overlay network.

To setup the Kafka cluster, you would need the similar steps with setting up ZooKeeper cluster. There are good discussions in related questions, get zookeeper running in docker swarm mode, and handle database replication in docker swarm.