I'm trying to get Kafka up and running on my Mac using docker compose.
This is my docker-compose.yml file:
version: '2'
services:
zookeeper:
image: ********
network_mode: "host"
hostname: "zookeeper"
environment:
- "MYID=1"
ports:
- "2181:2181"
- "3888:3888"
mysql:
image: *******
network_mode: "host"
hostname: "mysql"
environment:
- "MYSQL_ROOT_PASSWORD=password"
ports:
- "3306:3306"
schema-registry:
image: ********
network_mode: "host"
hostname: "schema-registry"
environment:
- "ZOOKEEPER_URL=127.0.0.1:2181"
ports:
- "8081:8081"
kafka:
image: **********
network_mode: "host"
hostname: "kafka"
environment:
- "SERVICE_NAME=localhost"
- "SERVICE_TAGS=syracuse-dev"
- "KAFKA_ADVERTISED_HOST_NAME=localhost"
- "KAFKA_ZOOKEEPER_CONNECT=localhost:2181"
- "KAFKA_NUM_PARTITIONS=10"
- "KAFKA_LISTENERS=PLAINTEXT://:9092"
- "KAFKA_BROKER_ID=1"
- "KAFKA_DEFAULT_REPLICATION_FACTOR=1"
ports:
- "9092:9092"
- "7203:7203"
Everything gets up and running with the exception of Kafka. As Kafka loads it looks for Zookeeper once found I receive the following error.
Found zookeeper
Error: Exception thrown by the agent : java.net.MalformedURLException: Local host name unknown: java.net.UnknownHostException: moby: moby: unknown error
I was able to get Kafka up and running by removing the "network_mode: "host" lines from each container. And setting the zookeeper url to: "zookeeper:2181"
It's unclear to me what the network_mode does and why it impeded kafka from running. I'm hoping someone can shed some light onto this and educate me.
much appreciated