Hi, I’m the Toradex AI Assistant.
I might make mistakes or occasionally get you wrong. Our support team will step in if needed.
Hello Anurag,
I understand you’re having trouble accessing a USB PnP microphone from within a container on your Verdin iMX8M Plus running Torizon OS. Let me provide guidance on the correct container setup for USB audio devices.
Container Configuration for USB Audio Devices
For audio devices in Torizon OS containers, you need to ensure proper device access. The standard approach is to mount the /dev directory and provide access to all audio devices(1):
docker run -it --rm -v /dev:/dev --device-cgroup-rule='c 89:* rmw' <container_namespace>
(1)
This command gives the container access to all I2C buses with the --device_cgroup_rules flag, but the same principle applies to audio devices(1).
Recommended Audio Setup in Torizon Containers
Direct ALSA Access (Recommended)
The recommended approach for audio in Torizon containers is direct ALSA usage(2). Here’s the minimal setup:
- Expose
/dev/snd devices:
docker run -it --rm --device /dev/snd <your-container>
(2)
- Verify device detection:
Inside your container, check if your USB microphone is detected:
aplay -l
cat /proc/asound/cards
(2)
Why PulseAudio Isn’t Recommended
PulseAudio and PipeWire aren’t enabled or recommended in standard Torizon images(2). They require additional configuration to run properly in containers due to user session management, permissions, and shared resources, which adds complexity and overhead contrary to Torizon design principles(2).
Troubleshooting USB Audio Detection
If your USB microphone still isn’t detected after mounting /dev/snd, try these steps:
- Check if the device appears on the host:
lsusb
dmesg | grep -i audio
- Use software mixing for better compatibility:
For recording or playback that requires software mixing, use the plug:dmix ALSA device(2):
arecord -D plug:dmix -f cd test.wav
- Alternative device access method:
You can also mount the entire /dev directory with device cgroup rules(1):
docker run -it --rm -v /dev:/dev --device-cgroup-rule='c 89:* rmw' <container_namespace>
Container Run Command Example
Here’s a complete example for running a container with USB audio support:
docker run -it --rm \
--device /dev/snd \
-v /tmp:/tmp \
-v /var/run/dbus:/var/run/dbus \
--security-opt seccomp=unconfined \
<your-container-image>
(2)
This setup should allow your C-Media USB microphone to be accessible via ALSA within your container.
Best regards, Toradex AI Assistant.
Did you like my answer?

If I answered your question, please tick the “Solution” checkbox.
For follow-up questions to me, please use @ToradexAI in your post.