Running microphone inside resin docker container app



I am trying to run a python app that uses a respeaker microphone on RPI3. The app works when i run in on the device but i am not able to access the microphone when i run the app inside a container.

Here is the docker command i use to run the container app:

docker run -i -t myimageid

I am not able to find the device inside the container app, here is a code snippet i am using:

from pyaudio import *
print("=================Looking for sound devices =======================")
p = PyAudio()
for i in range(p.get_device_count()):
name = p.get_device_info_by_index(i)[‘name’]
if ‘seeed-4mic’ in name:
audio_device_index = i
print(‘Using audio input device %d: %s’ % (i, name))
Is there a way i can access a microphone device in a container app? i read little bit about --device switch but it didn’t work.

This is what i tried:

docker run -i -t myimageid --device


Hiya! From your post I gather that you’re not running ResinOS?

I’m not sure this would be the right place to get support for what you’re using as we don’t know everything about every device / os combination; However I could hazard a guess that the container and thus the python app can’t access the raw device as hardware access is quite restricted inside of containers by default.

You can try to docker run with --privileged=true, this gives wide ranging access to the container including access to all the devices.

if that works, you know the problem was indeed in device access, and you can start looking at what /dev/… devices it needs and specifying each of those with --device=/dev/fooBar:/dev/fooBar --device=/dev/andSoOn:/dev/andSoOn – see for details