Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save ringods/b1877c9c34933a89e48b5b8e15174009 to your computer and use it in GitHub Desktop.
Save ringods/b1877c9c34933a89e48b5b8e15174009 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=zookeeper:2181
- KAFKA_ADVERTISED_LISTENERS=PLAINTEXT://zookeeper:9092
- KAFKA_OFFSETS_TOPIC_REPLICATION_FACTOR=1
@ringods
Copy link
Author

ringods commented May 21, 2018

@cmeiklejohn when using Docker compose, each of the docker containers gets an /etc/hosts file pre-filled with the hostnames pointing to your services: zookeeper & kafka. When resolving one service from the other, just use the service name you specified in your docker-compose.yml.

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