Can't make audio device to work on AWS [solved]

I’m trying so dockerize a selenium python script that uses microphone and audio for webrtc calls.
I can’t make that work.

Expected behavior

chrome should detect an audio device

Actual behavior

No audio device is detected

Additional Information

Steps to reproduce the behavior

i’ve tried specifying the device:

  • docker run -d --device /dev/snd -p 4444:4444 -p 5900:5900 -v /dev/shm:/dev/shm selenium/standalone-chrome-debug

and by mounting /dev/snd

  • docker run -d -v /dev/snd:/dev/snd -p 4444:4444 -p 5900:5900 -v /dev/shm:/dev/shm selenium/standalone-chrome-debug

In no case was the audio working.

docker info:


Containers: 11
Running: 2
Paused: 0
Stopped: 9
Images: 92
Server Version: 18.09.3
Storage Driver: overlay2
Backing Filesystem: extfs
Supports d_type: true
Native Overlay Diff: true
Logging Driver: json-file
Cgroup Driver: cgroupfs
Plugins:
Volume: local
Network: bridge host macvlan null overlay
Log: awslogs fluentd gcplogs gelf journald json-file local logentries splunk syslog
Swarm: inactive
Runtimes: runc
Default Runtime: runc
Init Binary: docker-init
containerd version: e6b3f5632f50dbc4e9cb6288d911bf4f5e95b18e
runc version: 6635b4f0c6af3810594d2770f662f34ddc15b40d
init version: fec3683
Security Options:
seccomp
Profile: default
Kernel Version: 4.9.0-8-amd64
Operating System: Debian GNU/Linux 9 (stretch)
OSType: linux
Architecture: x86_64
CPUs: 1
Total Memory: 1.956GiB
Name: docker-test
ID: CI2Z:IPXQ:NOIV:EOEK:NSZU:LHMR:YBWP:X3NZ:S4O5:JI4E:JWFX:RI7Q
Docker Root Dir: /var/lib/docker
Debug Mode (client): false
Debug Mode (server): false
Registry: https://index.docker.io/v1/
Labels:
Experimental: false
Insecure Registries:
127.0.0.0/8
Live Restore Enabled: false
Product License: Community Engine

WARNING: No swap limit support


OS:
cat /etc/debian_version
9.6

ls -l /dev/snd/
total 0
crw-rw---- 1 root audio 116, 1 Mar 25 16:37 seq
crw-rw---- 1 root audio 116, 33 Mar 25 16:37 timer

any help would be greatly appreciated

In the title you write you are on AWS, so the question is: which audio device to you try to use there?
On a Debian Stretch notebook /dev/snd looks like this:

drwxr-xr-x  2 root root       60 Mär 26 08:07 by-path
crw-rw----+ 1 root audio 116,  2 Mär 26 08:07 controlC0
crw-rw----+ 1 root audio 116,  7 Mär 26 08:07 hwC0D0
crw-rw----+ 1 root audio 116,  8 Mär 26 08:07 hwC0D3
crw-rw----+ 1 root audio 116,  4 Mär 26 08:07 pcmC0D0c
crw-rw----+ 1 root audio 116,  3 Mär 26 08:07 pcmC0D0p
crw-rw----+ 1 root audio 116,  5 Mär 26 08:07 pcmC0D3p
crw-rw----+ 1 root audio 116,  6 Mär 26 08:07 pcmC0D7p
crw-rw----+ 1 root audio 116,  1 Mär 26 08:07 seq
crw-rw----+ 1 root audio 116, 33 Mär 26 08:07 timer

Hello and thanks for replying,

I also have seq and timer, that’s it.
In any case, i solved it by using pulseaudio’s server and creating fake audios like so:


USER root
# Install pulse audio and python
RUN apt-get -qq update && apt-get -qq install -y pulseaudio pavucontrol python python3-pip
RUN pip3 install selenium

# Copy the media folder of this repo to opt/media in the container
#RUN mkdir -p /opt/media
#COPY media /opt/media/

# Use custom entrypoint
COPY entrypoint.sh /opt/bin/entrypoint.sh

USER seluser

ENTRYPOINT ["sh", "/opt/bin/entrypoint.sh"]

and entrypoint:

#!/usr/bin/env bash

# Load pulse audio
pulseaudio -D --exit-idle-time=-1
# Create a virtual speaker output
pactl load-module module-null-sink sink_name=SpeakerOutput sink_properties=device.description="Dummy_Output"
# Create a virtual microphone
pacmd load-module module-virtual-source source_name=VirtualMicrophone

# Stand up a local server that serves the media files within opt/media
python -m SimpleHTTPServer &>/dev/null

# Start Selenium Test
cd /apps
python3 selenium-start.py

and selenium_start.py is the actual selenium test, which should include something like:

chrome_options = Options()
prefs = {"profile.default_content_setting_values.notifications" : 2}

chrome_options.add_argument("--use-fake-ui-for-media-stream")
chrome_options.add_argument("--window-size=1920x1080")
chrome_options.add_argument("--headless")
chrome_options.add_argument('--no-sandbox')
chrome_options.add_argument("--disable-dev-shm-usage")
chrome_options.add_experimental_option("prefs",prefs)
browser = webdriver.Chrome(chrome_options=chrome_options)

this made it work for me!

Thanks!

1 Like