Search code examples
cassandranosqldatastax

Connection to container of DataStax Distribution of Apache Cassandra


I created Docker container of DataStax Distribution of Apache Cassandra (DDAC):

docker pull datastax/ddac
docker run -e DS_LICENSE=accept --name ddac -d datastax/ddac

docker ps

enter image description here


I got the error while connecting to the node via Datastax DevCenter:

enter image description here

The same error occurred during try connect via 7000 and 7199 ports.


How to connect to DDAC node deployed in a docker container?


UPDATE

I disabled Windows Firewall just in case. Use docker run -e DS_LICENSE=accept --name ddac -p 9042:9042 -d datastax/ddac and got same error:

The specified host(s) could not be reached. All host(s) tried for query failed (tried: localhost/0:0:0:0:0:0:0:1:9042 (com.datastax.driver.core.exceptions.TransportException: [localhost/0:0:0:0:0:0:0:1] Channel has been closed), localhost/127.0.0.1:9042 (com.datastax.driver.core.exceptions.TransportException: [localhost/127.0.0.1] Channel has been closed))
[localhost/0:0:0:0:0:0:0:1] Channel has been closed
[localhost/127.0.0.1] Channel has been closed

enter image description here


Solution

  • That happens because container has it's own IP, and you need to either connect to it - you can get the IP of container with

    docker inspect -f '{{range .NetworkSettings.Networks}}{{.IPAddress}}{{end}}' ddac
    

    or expose Cassandra ports on the host, so you can connect via localhost - this is done via -p flag of docker run:

    docker run -e DS_LICENSE=accept --name ddac --rm -p 9042:9042 -d datastax/ddac