I am trying to create a new docker container for Cassandra CQL which connects to Cassandra cluster that is running as another docker container.
Current situation:
I have created a new Cassandra image "cassandra" and container named "container-node" by executing below commands:
- docker pull cassandra
- docker images | grep cassandra
- docker run -d --name cassandra-node --publish 9042:9042 cassandra
- Connect to the container: docker exec -it cassandra-node bash (Connected to Test Cluster at 127.0.0.1:9042)
Keyspace creation
- Create Keyspace: CREATE KEYSPACE first_keyspace WITH replication = {'class': 'SimpleStrategy', 'replication_factor' : 1}
- Connect to Keyspace: USE first_keyspace
- Create table: CREATE TABLE first_keyspace.user (USERID int PRIMARY KEY, USERNAME text, CITY text); Insert data:
- INSERT INTO USER (USERID, USERNAME, CITY) VALUES (1, 'JOHN','PARIS');
- INSERT INTO USER (USERID, USERNAME, CITY) VALUES (2, 'ABD','SAFRICA');
- Fetch data: select * from user;
Problem statement in details
Wants to create a new Docker Container (Using Dockerfile) for CQL (cqlsh) which would perform below tasks:
- Connect to Cassandra cluster which running as Docker container (cassandra-host)
- Perform all task Add / Update / Delete function reading from source.sql file.
I would like to know where I can start. Any help, pointers would be grateful.
docker exec -ti running_image cqlsh? - Alex Ott