-
Notifications
You must be signed in to change notification settings - Fork 280
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Create keyspace on startup #104
Comments
Hi all, I have the same issue, is there one way to load a script after cassandra is ready? I'm using Vagrant + docker-compose on Win 7. |
Hi i have the same issue as well. I would like to configure a keyspace for my integration tests. I'm using bitbucket pipeline and i have the following setup:
I would like to have an environment variable to set the default keyspace, with an default strategey. Otherwise provisioning of an running cassandra db must be done with another docker container... Thank you very much - Not sure if this issue is a problem of the docker image itself. |
Hey guys, hope this helps ;-) |
@dschroe can you add a README with a short example about how to run your image? |
@dschroe not working, the CQL scripts are never executed |
Can you share your configuration pls? My dummy-configuration (docker-compose and .cql file) looks like this:
and it works fine for me. |
@dschroe Thanks for sharing! It works with this solution https://stackoverflow.com/a/46037377 |
I cannot use image: dschroe/cassandra-docker from dokerhub, but I can build from Dockerfile of repository @dschroe provided, ie: git clone https://github.com/dschroe/cassandra-docker . docker-compose.yml version: "2.1"
services:
cassadnra:
image: 127.0.0.1:5000/cassandra
build: .
restart: unless-stopped
ports: ["9042:9042"]
volumes:
- cassandra-data:/var/lib/cassandra
- cassandra-data:/home/cassandra/.cassandra
- ./docker-entrypoint-initdb.d:/docker-entrypoint-initdb.d
networks: [backing-services]
volumes:
cassandra-data: {}
networks:
backing-services: docker-entrypoint-initdb.d/init.cql CREATE KEYSPACE IF NOT EXISTS demo WITH replication =
{'class':'SimpleStrategy','replication_factor':'1'}; and then docker-compose up --build
# ...
cassadnra_1 | INFO [Native-Transport-Requests-2] 2017-10-06 20:59:03,847 MigrationManager.java:310 - Create new Keyspace: KeyspaceMetadata{name=demo, ... Regards, |
@daggerok I am using DockerToolbox under Windows 10, it seems the |
Hi @hantsy, unfortunately I have not tested it using toolbox on Windows 10 Regards |
@dschroe Your script worked for me on OSX. Thanks. |
Closing in favor of #104 (comment) / https://stackoverflow.com/a/46037377/433558:
👍 |
It is a very common use-case in software development. I do not like the workaround, because it means so many people now need to build their own C* Docker Images. I would much prefer to see support for this Issue in the official Docker image. |
I was able to initialize Cassandra without a new Docker image by inspiring above comments. I have added version: '2.1'
...
cassandra:
image: cassandra:3.11.2
volumes:
- "./cassandra-init.sh:/cassandra-init.sh"
command: "sh /cassandra-init.sh"
... But called cat >/import.cql <<EOF
DROP keyspace test;
CREATE keyspace test with replication = {'class':'SimpleStrategy', 'replication_factor' : 1};
EOF
# You may add some other conditionals that fits your stuation here
until cqlsh -f /import.cql; do
echo "cqlsh: Cassandra is unavailable to initialize - will retry later"
sleep 2
done &
exec /docker-entrypoint.sh "$@" |
Why the issue has been closed? Has someone found already a solution? |
Hi, docker-compose.yml
cassandra-init.sh
|
Thanks for your script! I got it working by adding a
|
Is there any way to copy a .cql script into the cassandra image which gets automatically executed as soon as cassandra is fully initialized and available on port 9042?
The text was updated successfully, but these errors were encountered: