alltej
alltej

Reputation: 7285

Cannot connect to local datastax cassandra running in docker

I executed this docker command to run instance of datastax cassandra:

docker run -p 9042:9042 -e DS_LICENSE=accept --rm --name my-dse -d datastax/dse-server:6.8.2 -s

Then this to run instance of the datastax studio:

docker run -e DS_LICENSE=accept --link my-dse --name my-studio -p 9091:9091 -d datastax/dse-studio

When I open the browser at http://localhost:9091 to create the connection, I get this error:

All host(s) tried for query failed (tried: /127.0.0.1:9042 (com.datastax.driver.core.exceptions.TransportException: [/127.0.0.1:9042] Cannot connect))

I checked the cassandra instance running in docker and I can connect using cqlsh:

$ docker exec -it my-dse bash -c "cqlsh -u cassandra -p cassandra"
Connected to Test Cluster at 127.0.0.1:9042.
[cqlsh 6.8.0 | DSE 6.8.2 | CQL spec 3.4.5 | DSE protocol v2]
Use HELP for help.
cassandra@cqlsh> 

This is based on the instructions here: https://www.datastax.com/blog/2019/03/running-dse-microsoft-windows-using-docker

Upvotes: 2

Views: 1224

Answers (2)

Dave Decicco
Dave Decicco

Reputation: 11

Try querying the IP Address of the container running the my-dse container using the following command from a command prompt:

docker inspect my-dse | FINDSTR "IPAddress"

You should be able to use that IP address as the Host in the DataStax Studio connection.

Upvotes: 1

Alex Ott
Alex Ott

Reputation: 87164

Instead of 127.0.0.1:9092 or localhost:9042 you either need to specify my-dse:9042 or your_machine_ip:9042. The main problem is that for every Docker image, the localhost is uniq to that container, and in the Studio container there is no DSE process listening on the port 9042

Upvotes: 0

Related Questions