0

I have a problem setting up a Docker image that interacts with a USB device on Ubuntu 18.04. I get the following errors when running the rmmod command in a script run from within the container to begin interacting with this USB device:

rmmod: ERROR: Module ftdi_sio is not currently loaded
rmmod: ERROR: Module usbserial is not currently loaded

I have got this to work when running the image from a machine running Ubuntu 20.04 by installing linux-modules-extra-5.8.0-53-generic in the Docker image. However, when I try to install the equivalent (linux-modules-extra-4.15.0-143-generic I think) in the Docker image running on Ubuntu 18.04 I get the following error when trying to build the image:

E: Unable to locate package linux-modules-extra-4.15.0-143-generic
E: Couldn't find any package by glob 'linux-modules-extra-4.15.0-143-generic'
E: Couldn't find any package by regex 'linux-modules-extra-4.15.0-143-generic'

Maybe I’m just trying to install the wrong thing? I’ve also tried installing linux-modules-4.15.0-143-generic but this gives the same error. Any ideas where I’m going wrong?

EDIT: It may be relevant to note that whilst I want to run my Docker image on a Ubuntu 18.04 machine, it is actually running a Ubuntu 20.04-based image. I guess that, because the running container inherits the host machine kernel, I need the corresponding linux-modules-extra version installed in the image which would be 4.15.0-143-generic?

Pyy
  • 327
  • 6
  • 23
  • You pretty much can't interact with kernel modules from inside a container, for a couple of reasons. You need to manage those from the host. – David Maze Jun 02 '21 at 16:12
  • Thanks for the comment. This is confusing because when I run the Docker image from my `Ubuntu 20.04` machine I can install `linux-modules-extra-5.8.0-53-generic` and use `lsmod` in the container to show that the `ftdi_sio` and `usbserial` modules exist and I can connect to my USB device. This just isn't the case on my `Ubuntu 18.04` machine. – Pyy Jun 03 '21 at 12:41
  • Kernel modules are extremely specific to the kernel they're built for. If your image has a module built against the Ubuntu `5.8.0-53-generic` kernel but the system has any other kernel at all -- the host has taken a patch release, you're running on a different Linux distribution, a different Ubuntu kernel variant is installed -- it won't run. You also need to disable some important security controls to be able to `lsmod` from within a container. Since it's so specific to the host it's running on, this needs to be done from the host system and not a container. – David Maze Jun 03 '21 at 13:30

0 Answers0