cassandra-docker icon indicating copy to clipboard operation
cassandra-docker copied to clipboard

Does port mapping work?

Open ghost opened this issue 9 years ago • 5 comments

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.

ghost avatar Apr 18 '15 02:04 ghost

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" [email protected] 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.

tobert avatar Apr 18 '15 09:04 tobert

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)

pofallon avatar Apr 19 '15 21:04 pofallon

Alright, thanks :)

ghost avatar Apr 22 '15 04:04 ghost

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

kbowerma avatar Apr 22 '15 18:04 kbowerma

@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... ;)

tobert avatar Jul 09 '15 17:07 tobert