tobert / cassandra-docker

Cassandra in Docker
https://registry.hub.docker.com/u/tobert/cassandra/
Apache License 2.0
130 stars 56 forks source link

Does port mapping work? #26

Open ghost opened 9 years ago

ghost commented 9 years ago

Hi,

First of all, I appreciate your project.

However, I'm still bit confused of how docker expose the Cassandra ports through the host machine.

I assumed that

"docker run -d -p 9160:9160 -v /srv/cassandra:/data tobert/cassandra" would work.

But it failed to run with error, so I just tried the example as it is, "docker run -d -v /srv/cassandra:/data tobert/cassandra".

The docker ran without anyproblem, but the cassandra ports, 7000, 7199, 9042 and 9160 are still not exposed.

tcp 0 0 0.0.0.0:22 0.0.0.0:* LISTEN -
tcp 0 0 127.0.0.1:631 0.0.0.0:* LISTEN -
tcp 0 0 127.0.0.1:25 0.0.0.0:* LISTEN -
tcp6 0 0 :::22 :::* LISTEN -
tcp6 0 0 ::1:631 :::* LISTEN -
tcp6 0 0 ::1:25 :::* LISTEN -

My question is, does this project support port mapping, and I missed something? Or it does not support?

Thanks.

tobert commented 9 years ago

The dockerfile exposes all the common ports. To be honest I rarely use the default Docker networking so I will take some time and try it and get you an answer. It should work and will be fixed if I missed something. On Apr 18, 2015 11:23 AM, "Sky Moon" notifications@github.com wrote:

Hi,

First of all, I appreciate your project.

However, I'm still bit confused of how the docker expose port through host machine.

I assumed that

"docker run -d -p 9160:9160 -v /srv/cassandra:/data tobert/cassandra" would work.

But it was not, so I just tried the example as it is, docker run -d -v /srv/cassandra:/data tobert/cassandra.

However, the cassandra ports, 7000, 7199, 9042 and 9160 are still not exposed.

tcp 0 0 0.0.0.0:22 0.0.0.0:* LISTEN -

tcp 0 0 127.0.0.1:631 0.0.0.0:* LISTEN -

tcp 0 0 127.0.0.1:25 0.0.0.0:* LISTEN -

tcp6 0 0 :::22 :::* LISTEN -

tcp6 0 0 ::1:631 :::* LISTEN -

tcp6 0 0 ::1:25 :::* LISTEN -

My question is, does this project support port mapping, and I missed something? Or it does not support?

Thanks.

— Reply to this email directly or view it on GitHub https://github.com/tobert/cassandra-docker/issues/26.

pofallon commented 9 years ago

I've run it as follows: docker run --name=n1 -d -p 9042:9042 tobert/cassandra and be able to connect to it via cqlsh [docker host ip] (with an installation of cqlsh outside of the Cassandra cluster)

ghost commented 9 years ago

Alright, thanks :)

kbowerma commented 9 years ago

I find the port mapping cumbersome so here is what I do (on the mac) I just expose the ports and don't bother with mapping.EXPOSE 22 7000 7199 9042 9160 61621 as in @tobert example

On a mac you have to use boot2docker (which can act as a gateway) which in my case is 192.168.59.103 and my docker network is 172.17.0.x or in network terms in 172.17.0.0/24 so I just add a route to the docker network with the boot2docker as a gateway.

sudo route add 172.17.0.0/24 192.168.59.103

Now I can do a docker inspect on my cassandra node and hit it directly

tobert commented 9 years ago

@kbowerma that's pretty cool. Is there a blog or something I can point to for that trick? A PR to add a note to the README would be cool... ;)