How to manage Kolibri content in kolibri Docker container

We are trying to setup kolibri as docker container. would like to know how to manage content.

how to upload content to volume and do we need to setup database to manage it?

Thanks,
Dhanabal M

Hi!

If you’re not modifying the Kolibri installation from within the container, the default content directory is going to be ~/.kolibri/content.

You could mount the volume at Kolibri’s home directory, where the user databases and such are stored. This would be ~/.kolibri/ by default. You could then mount that volume to any Kolibri container and not lose any data!

Setting up a database is not required - Kolibri uses python’s SQL library by default and saves the database in the form of files, which live inside of the home directory (~/.kolibri/ by default).

If you’d like to post your Dockerfile, we may be able to provide some more guidance. Feel free ask any more questions you might have!

We are still preparing docker file, if you have proper dockerfile with volume mount and python SQL library which is working fine, please provide us it would be helpful to setup our environment.

Just to be clear, the Python SQL library doesn’t need to be installed - it’s already in Python!

The dockerfile could be extremely simple - it all really depends on your use case! But this is one I’ve just thrown together with good results:

FROM ubuntu:bionic

ENV DEBIAN_FRONTEND=noninteractive

RUN apt update && apt install -y python-pip

RUN pip install kolibri

CMD kolibri start --foreground

You could simply save this into a file named Dockerfile, then run docker build. If you want, you could tag it with:

docker build -t kolibri

So far, everything I’ve described is happening during build time. The volume mount, however, has to happen during runtime. So if you build the image and tag it using -t kolibri, as described above, you could do something like:

docker run -it --rm -v kolibri_home:/root/.kolibri cloud-kolibri bash

This will run a docker container with command line input that is automatically removed when finished. It should also create a docker volume named kolibri_home if one doesn’t already exist.

This is a very rudimentary setup - I didn’t want to assume anything about your use case. Please feel free to modify according to your use case, as you probably have your own reasons for using Docker containers to begin with.

ok thanks for sharing.

so we need to keep all the content on /kolibri_home on host machine and map that with kolibri docker container. if we have content in drive how can we sync kolibri content to /kolibri_home? what is the recommended way?

No, actually. This notation:

is used to mount a Docker Volume; not that there is no / before kolibri_home. I assumed this is what was desired because of this portion of your comment above:


I’m need a bit more detail to answer – do you mean a physical hard drive? Or a cloud service like Google Drive?

If it’s a physical drive, the notation in the command above would need to be tweaked to mount a location on your machine. For example, if your existing content lived in /media/volume1/.kolibri, the command would look like this:

docker run -it --rm -v /media/volume1/.kolibri:/root/.kolibri cloud-kolibri

It would be really helpful to have some context behind the use of Docker.

Thanks,
David