3

I'm trying to create a Docker image that works with a speaker and microphone.

I've got it working with Ubuntu as host using:

docker run -it --device /dev/snd:/dev/snd <docker_container>

I'd also like to be able to use the Docker image on windows and mac hosts, but can't find the equivalent of /dev/snd to make use of the host's speaker/microphone.

Any help appreciated

1
  • I see a 6 year old question which says no way Jose to the OSX question apple.stackexchange.com/questions/47822/… however as we all know at some point audio gets sent down into hardware so there is still hope on the OSX front ... my take is its intentional - consider you being the owner of media content : would you allow software to execute which exposed the un-DRM-ized raw streaming audio to get siphoned off ? do some digging on notion of a Virtual Audio Device ... on windo$e its called a virtual audio cable Oct 19, 2018 at 21:11

1 Answer 1

3

I was able to get playback on Windows using pulseaudio.exe.

1] Download pulseaudio for windows: https://www.freedesktop.org/wiki/Software/PulseAudio/Ports/Windows/Support/

2] Uncompress and change the config files.

2a] Add the following line to your $INSTALL_DIR/etc/pulse/default.pa:

load-module module-native-protocol-tcp listen=0.0.0.0 auth-anonymous=1 

This is an insecure setting: there are IP-based ones that are more secure but there's some Docker sorcery involved in leveraging them I think. While the process is running anyone on your network will be able to push sound to this port; this risk will be acceptable for most users.

2b] Change $INSTALL_DIR/etc/pulse//etc/pulse/daemon.conf line to read: exit-idle-time = -1

This will keep the daemon open after the last client disconnects.

3) Run pulseaudio.exe. You can run it as

start "" /B "pulseaudio.exe"

to background it but its tricker to kill than just a simple execution.

4) In the container's shell:

export PULSE_SERVER=tcp:127.0.0.1

One of the articles I sourced this from (https://token2shell.com/howto/x410/enabling-sound-in-wsl-ubuntu-let-it-sing/) suggests recording may be blocked in Windows 10.

Your Answer

Reminder: Answers generated by Artificial Intelligence tools are not allowed on Stack Overflow. Learn more

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

Not the answer you're looking for? Browse other questions tagged or ask your own question.