Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Save cmeiklejohn/02ef7ed8ff8a7aaa4e02d353ecbf3ada to your computer and use it in GitHub Desktop.
Save cmeiklejohn/02ef7ed8ff8a7aaa4e02d353ecbf3ada to your computer and use it in GitHub Desktop.
version: '2'
services:
zookeeper:
image: "confluentinc/cp-zookeeper:4.1.0"
ports:
- "2181:2181"
expose:
- "2181"
environment:
- ZOOKEEPER_CLIENT_PORT=2181
kafka:
image: "confluentinc/cp-kafka:4.1.0"
hostname: kafka
links:
- zookeeper
ports:
- "9092:9092"
expose:
- "9092"
environment:
- KAFKA_ZOOKEEPER_CONNECT=localhost:2181
- KAFKA_ADVERTISED_LISTENERS=PLAINTEXT://localhost:9092
- KAFKA_OFFSETS_TOPIC_REPLICATION_FACTOR=1
@ericmoritz
Copy link

You can refer to zookeeper using the hostname zookeeper when using docker-compose

How you connect to the instances from your machine depends on what you're using for docker.

docker-machine runs docker inside a VM so you have to use the VMs IP which you can find by running docker-machine env

IIRC docker for Mac allows you to use localhost, I'd assume docker for Windows can as well.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment