Executing startup script on each reboot of device

Good day,
We run a multi container application on our devices,
and for one I need to reconfigure some driver by using modprobe.
This command works fine when executed on the host (e.g. via SSH)
but fails when used in a script inside a container.
Is there a possibility to execute a script before the docker containers are built, or whenever the device is restarted?

I personally am fairly new to this architecture, if I can provide any additional info, just let me know.

Thanks in advance for your kind help,
Greetings, Tarek

To elaborate a little bit more:
I need to execute
rmmod uvcvideo
modprobe uvcvideo nodrop=1 timeout=5000 quirks=0x80
on the host system, whenever the system restarts.
The modprobe command can not be executed on the container.
I also tried simply editing the respecitve files under /sys/module/uvcvideo/parameters
but that seemed to have no effect.

One of the differences between a single container and multi-container mode is that the containers are not run in privileged mode by default – as such they no longer have direct access to hardware.

You can enable privileged mode on a per-container bases, the docker compose documentation has the details on how to do that:

1 Like

Thank you for your answer. However privileged mode is actually already activated.
The output of running “modprobe uvcvideo nodrop=1 timeout=5000 quirks=0x80” is the following:
modprobe: ERROR: …/libkmod/libkmod.c:557 kmod_search_moddep() could not open moddep file ‘/lib/modules/4.9.59/modules.dep.bin’
I saw on another thread, that this might be related to the /lib/modules/ folder not being linked from the host system, but I do not know how to fix this. (It is indeed not existing in the container)

Ah yes that makes sense. Mounting /lib/modules in a container is controlled by a labels:

1 Like

Thank you very much, that was exactly what I was looking for!

1 Like