We currently use two custom kernel modules in our multi-container app (iwlwifi and v4l2loopback) and currently the way we ensure they are loaded is via a standalone kernel module container, whose sole purpose is to bind mount the /lib/modules and /lib/firmware folders using the io.balena.features.kernel-modules
and io.balena.features.firmware
labels in docker-compose.yml, modifying them to be read-write and installing the modules / firmware. Then, all other containers that require the device functionality also have the two labels applied and can use the devices.
This feels like a less than ideal approach as it requires a separate container just to deploy the modules, and then I validate that the modules are actually installed in the containers that use them. We use a custom base image that is based off of balenalib/jetson-nano-ubuntu
and I’m wondering if it would be possible build the drivers and load them into the base image. My only question is how to actually do this, because presumably they can’t be installed in the builder, and rather they would need to be installed using the startup script. The problem is that we have multiple containers that require the modules, so I’m not sure I would want multiple containers having read/write access and attempting to install the modules.
Has anyone else used custom kernel modules, and if so how is it typically done? Is the kernel module container the best approach, or is there a different way to do this that would work better?