Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Can't connect to zk on localhost? #26

Closed
mikewrighton opened this issue Oct 26, 2016 · 2 comments · May be fixed by #30
Closed

Can't connect to zk on localhost? #26

mikewrighton opened this issue Oct 26, 2016 · 2 comments · May be fixed by #30
Labels

Comments

@mikewrighton
Copy link

I'm having trouble running this container against my local, native instance of zookeeper (native docker on OS/X). Should this work?

I've tried:

docker run ches/kafka
docker run --env ZOOKEEPER_IP=127.0.0.1 ches/kafka
docker run --env ZOOKEEPER_CONNECTION_STRING=localhost:2181 ches/kafka

but always get the error:

[2016-10-26 22:00:20,317] WARN Session 0x0 for server null, unexpected error, closing socket connection and attempting reconnect (org.apache.zookeeper.ClientCnxn)
java.net.ConnectException: Connection refused
    at sun.nio.ch.SocketChannelImpl.checkConnect(Native Method)
    at sun.nio.ch.SocketChannelImpl.finishConnect(SocketChannelImpl.java:717)
    at org.apache.zookeeper.ClientCnxnSocketNIO.doTransport(ClientCnxnSocketNIO.java:361)
    at org.apache.zookeeper.ClientCnxn$SendThread.run(ClientCnxn.java:1081)
@xrl
Copy link

xrl commented Jan 18, 2017

Unless otherwise specified, docker run creates a new container-specific network. You probably want to share your network with your host:

docker run --net=host ches/kafka 

or similar.

Hope that helps!

@ches ches added the question label Apr 8, 2017
@ches
Copy link
Owner

ches commented Apr 9, 2017

Hi Mike, sorry this is ages late—

Unfortunately --network=host as @xrl suggested doesn't work as expected on macOS, that would otherwise be the most straightforward solution when you want to share a service from the host with containers. This is surprising since they have made docker run -p port mapping to the host work.

It should work on your host's external IP though, if you've got ZooKeeper listening on 0.0.0.0 and that's acceptable:

$ docker run -e ZOOKEEPER_IP=$(ipconfig getifaddr en0) ches/kafka

assuming en0 is your connected interface. Since this IP probably changes, Docker suggests creating a stable alias to the loopback as a workaround, and that can let you avoid exposing ZK to the Internet too.

As a small clarification, docker run doesn't create a new network for every container, by default it connects containers to the built-in bridge network that appears in docker network ls. This corresponds to the docker0 interface which is now in the xhyve VM of current Docker on macOS, hence this difficulty 😞

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants