Riak-KV: how to create bucket in docker-compose file?

205 Views Asked by At

I try to use the original riak-kv image in docker-compose and I want on init add one bucket but docker-compose up won't start. How I can edit volumes.schemas to add bucket on init? Original image allows to add riak.conf file in docker-compose ? If yes, then how can I do that?

1

There are 1 best solutions below

0
Oresztesz On

Creating a bucket type with a custom datatype

I assume you want to create a bucket type when starting your container. You have to create a file in the /etc/riak/schemas directory with the bucket's name, like bucket_name.dt. The file should contain a single line with the type you would like to create (e.g. counter, set, map, hll).

You can also use the following command to create the file:

echo "counter" > schemas/bucket_name.dt

After that you have to just mount the schemas folder with the file to the /etc/riak/schemas directory in the container:

docker run -d -P -v $(pwd)/schemas:/etc/riak/schemas basho/riak-ts

Creating a bucket type with default datatype

Currently creating a bucket type with default datatype is only available if you add a custom post-start script under the /etc/riak/poststart.d directory.

Create a shell script with the command you would like to run. An example can be found here. You have to mount it as a read-only file into the /etc/riak/poststart.d folder:

docker run -d -P -v $(pwd)/poststart.d/03-bootstrap-my-datatype.sh:/etc/riak/poststart.d/03-bootstrap-my-datatype.sh:ro basho/riak-ts

References

See the whole documentation for the docker images here. The rest can be found in GitHub.

Also, the available datatypes can be found here.