Skip to content

Instantly share code, notes, and snippets.

@todgru
Last active April 8, 2024 19:56
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save todgru/42bcaa9b38498b266dc07d6bab100e27 to your computer and use it in GitHub Desktop.
Save todgru/42bcaa9b38498b266dc07d6bab100e27 to your computer and use it in GitHub Desktop.
Audio/sound from Docker container on M1 MacBook PRO 2019

Audio/sound from Docker container on M1 MacBook PRO 2019

Install pulseaudio with brew

brew install pulseaudio

NOTE: do not run pulseaudio as service wth brew. If started, stop the service.

brew services stop pulseaudio

Run as daemon:

pulseaudio --load=module-native-protocol-tcp --exit-idle-time=-1 --daemon

Verify running pulseaudio:

pulseaudio --check -v

Test docker audio:

Run a docker container and test sound. You should be able to hear the audio on your Mac.

docker run -it -e PULSE_SERVER=docker.for.mac.localhost \
  -v ~/.config/pulse:/home/pulseaudio/.config/pulse \
  --entrypoint speaker-test \
  --rm jess/pulseaudio -c 2 -l 1 -t wav

NOTE: the docker image used for this test jess/pulseaudio.

NOTE: for other systems, may need to use --device /dev/snd instead see: https://github.com/mviereck/x11docker/wiki/Container-sound:-ALSA-or-Pulseaudio

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment