Add a microphone using usb port to docker container

Hello,
I added a microphone using a USB device to an existing Docker container.
The docker container can read from the USB port but can not read from the microphone itself. It means the container identifies the USB port as empty.
How can I make the container read the microphone?

  • OS Version is ubuntu 20.04.3 LTS
  • App version is Docker Engine 20.10.10
    Thanks for your answers.

Hi

Can you provide how you start the container, if its docker-compose, please provide the content of the yml file.

BUT
it should be enough to add the usb device via --device
but if you remove the usb and add it again, you need to restart the container

Hi @terpz,
I am using a docker-compose file to start the container.

microphone:
 build:
  context: microphone
  dockerfile: ./dockerfile
 image: microphone
 container_name: microphone
 restart: "no"
 devices:
   - /dev/bus/usb:/dev/bus/usb

I think that I need to set the default input device (microphone) in the docker container to be the same as the system but I do not know how to do it. What do you think? How do I see the default input and output devices in the container and how to adjust them?

im afraid that you need to define the specific usb device that you want to use, and not just /dev/bus/usb

The specific USB device number changes every time I restart the computer.

okay, then i belive that solution is to run it in --privileged instead, and remove the --device part

I added a few minutes ago the privileged part but nothing changed. Do you know how do I see the default input and output devices in the container and how to adjust them?

Hi, without knowing what your container is runnig, but in linux you could try giving alsamixer a try.

I already set the default input device in the ubuntu system to be the microphone but the problem is the docker container reads all the inputs from USB ports although it should only take input from the microphone.