I want to run official Cassandra version 2.1.9 inside docker. Also, I want to have following ports mapping:
7000:7000
7001:7001
7199:7199
9042:9042
9160:9160
What command do I have to run in order to achieve this goal?
The format of the --publish command is [host port]:[container port] . So, if we wanted to expose port 8000 inside the container to port 8080 outside the container, we would pass 8080:8000 to the --publish flag. Start the container and expose port 8080 to port 8080 on the host.
To make a port available to services outside of Docker, or to Docker containers which are not connected to the container's network, use the --publish or -p flag. This creates a firewall rule which maps a container port to a port on the Docker host to the outside world.
You cannot do this via Docker, but you can access the container's un-exposed port from the host machine.
The official Cassandra image doesn't have 2.1.9. The closest is 2.1.15 which shouldn't have any compatibility issues. The easiest way to run it is:
docker run -d -p 7000:7000 -p 7001:7001 -p 7199:7199 -p 9042:9042 -p 9160:9160 cassandra:2.1.15
-p
publishes a ports from the image to a specific port number on the host. The Cassandra Dockerfile exposes exactly those ports. You'd probably want to give the container a --name
as well.
If you really want 2.1.9 you'll have to hunt for a non-official image or build your own.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With