Created
May 21, 2018 18:12
-
-
Save cmeiklejohn/02ef7ed8ff8a7aaa4e02d353ecbf3ada to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 |
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
I think the issue is
localhost
meaning the container's loopback instead of the host's loopback. I've used the host's IP address instead of localhost with some success.