I would like to create a docker file that will create a Cassandra image using the key space and schema already there when the image starts.
In general, how do you create a Docker file that will create an image that includes some steps that cannot be completed until the container is launched, at least for the first time?
I currently have two steps: create a cassandra image from an existing Docker file of a cassandra file that maps the volume to the CQL schema files in the temporary directory, and then run docker exec with cqlsh to import the schema after the image has been launched as a container .
But this does not create an image using a circuit - just a container. This container can be saved as an image, but it is cumbersome.
docker run --name $CASSANDRA_NAME -d \ -h $CASSANDRA_NAME \ -v $CASSANDRA_DATA_DIR:/data \ -v $CASSANDRA_DIR/target:/tmp/schema \ tobert/cassandra:2.1.7
then
docker exec $CASSANDRA_NAME cqlsh -f /tmp/schema/create_keyspace.cql docker exec $CASSANDRA_NAME cqlsh -f /tmp/schema/schema01.cql
This works, but it makes it impossible to use with tools like Docker, because the associated containers / services will also start and expect the circuit to be in place.
I saw one attempt when the cassandra process tried to run in the background in the Dockerfile during build, then cqlsh was executed, but I donβt think it worked too well.
source share