Search code examples
cassandradocker-composedatastax-enterprise

Docker With DataStax Connection Not Working


I wrote docker-compose.yml file which download the image from docker store. I had already subscribe that image in docker store and I am able to pull that image. Following are the services I am using on my compose file.

  • store/datastax/dse-server:5.1.6
  • datastax/dse-studio

The link which I followed to write the compose file is datastax/docker-images

I am running docker from Docker Toolbox because I am using Window 7.

version: '2'
services:
  seed_node:
    image: "store/datastax/dse-server:5.1.6"
    environment:
      - DS_LICENSE=accept
    # Allow DSE to lock memory with mlock
    cap_add:
    - IPC_LOCK
    ulimits:
      memlock: -1
  node:
    image: "store/datastax/dse-server:5.1.6"
    environment:
      - DS_LICENSE=accept
      - SEEDS=seed_node
    links:
      - seed_node
    # Allow DSE to lock memory with mlock
    cap_add:
    - IPC_LOCK
    ulimits:
        memlock: -1
  studio:
    image: "datastax/dse-studio"
    environment:
      - DS_LICENSE=accept
    ports:
      - 9091:9091

When I go the browser link for http://192.168.99.100:9091/ and try to have a connection I am getting the following errors:

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

Solution

  • Docker Compose creates a default internal network where all your containers get IP addresses and can communicate. The IP address you're using there (192.168.99.100) is the address of your host that's running the containers, not the internal IP addresses where the containers can communicate with each other on that default internal network. Port 9091 where you're running Studio is available on that external IP address because you exposed it in the studio service of your yaml:

    ports:
    - 9091:9091
    

    For Studio to make a connection to one of your nodes, you need to be using an IP on that internal network where they communicate, not on that external IP. The cool thing with Docker Compose is that instead of trying to figure out those internal IPs, you can just use a hostname that matches the name of your service in the docker-compose.yaml file.

    So to connect to the service you named node (i.e. the DSE node), you should just use the hostname node (instead of an IP) when creating the connection in Studio.