Transley Rodrigues
Transley Rodrigues

Reputation: 11

Cannot connect my springboot docker with my cassandra docker

I have some issues to dockerize my Spring boot Cassandra application. When I use Idea to run my project it's work fine correctly but when I turn my application into a docker container I have this issues : "RetryingCassandraClusterFactoryBean : All host(s) tried for query failed (tried: localhost/127.0.0.1:9042 (com.datastax.driver.core.exceptions.TransportException: [localhost/127.0.0.1:9042] Cannot connect))"

my application.properties: 
spring.data.cassandra.keyspace-name=keyspace
spring.data.cassandra.contact-points=127.0.0.1
spring.data.cassandra.port=9042
spring.data.cassandra.schema-action=create_if_not_exists
server.port=8081    

my cassandra :
cassandradb:
    image: "cassandra:latest"
    container_name: "cassandradb"
    ports:
      - "9042:9042"
      - "7191:7191"
      - "7001:7001"
      - "9160:9160"
      - "7000:7000"
    environment:
      CASSANDRA_CLUSTER: "myCluster"
      CASSANDRA_ENDPOINT_SNITCH: "GossipingPropertyFileSnitch"
      CASSANDRA_DC: "data"
      CASSANDRA_LISTEN_ADDRESS: "auto"

  photos:
    image: "photos:latest"
    container_name: "photo"
    ports:
      - "8081:8081"
    links:
      - "cassandradb"

Upvotes: 1

Views: 1264

Answers (2)

Omid Mohebbi
Omid Mohebbi

Reputation: 786

I develop a simple example about the CRUD spring boot application by Cassandra. You can check it in github. here are a few differences in the comparison of mine.

Upvotes: 0

Giga Kokaia
Giga Kokaia

Reputation: 929

Error happens, becouse your spring cant reach cassandradb. You should connect or via host ip, or usecassandradb` host, anc configure docker-compose.yml links part

Upvotes: 0

Related Questions