Passing local CQL commands file to Cassandra Docker container Passing local CQL commands file to Cassandra Docker container docker docker

Passing local CQL commands file to Cassandra Docker container


The container needs to be able to access the script first before you can execute it (i.e. the script file needs to be inside the container). If this is just a quick one-off run of the script, the easiest thing to do is probably to just use the docker cp command to copy the script from your host to the container:

$ docker cp createTables.cql container_name:/path/in/container

You should then be able to use docker exec to run the script at whatever path you copied it to inside the container. If this is something that's a work in progress and you might be changing and re-running the script while you're working on it, you might be better off mounting a directory with your scripts from your host inside the container. For that you'll probably want the -v option of docker run.

Hope that helps!


If you want docker container sees files in host system, the only way is to map volume. You can mapped current directory to /tmp and run command again docker exec -i cassandra_1 cqlsh -f /tmp/createTables.cql