Docker Community Forums

Share and learn in the Docker community.

Running multiple Docker container for Cassandra on same host

I have single server and need to run multiple services on it. Each service needs their own Cassandra DB. I can create separate image for services (each service is Spring boot application) and run it in separate containers, But challenge is running in separate container for Cassandra.
One container is running, say I ma giving following command
docker run --name cass-si --network=host -d cassandra:4.0
When I am running another docker with following command
docker run --name cass-ci --network=host -d cassandra:4.0
Then getting port is already bind 7199 (this is JMX port)
I changed the command to
docker run --name cass-si --network=host -dp 9042:9043 cassandra:4.0
This is also giving same error
Any help is appreciated

Why do you run Cassandra on the host network? I am not too familiar with cassandra so it may be required but the image description on Docker Hub contains “--network some-network”. You cannot run multiple instance of a container on host network unless you configure the app inside the container to listen on different port. So your options:

1 ) Run on one of the docker networks
1 / a ) and use a proxy/load balancer in front of them if necessary
1 / b ) forward different ports from host to the cassandra instance containers
2 ) Run on host network with custom configuration listening on different ports
3 ) Run on different servers in any available port