jessfraz / dockerfiles

Various Dockerfiles I use on the desktop and on servers.
https://blog.jessfraz.com/post/docker-containers-on-the-desktop/
MIT License
13.65k stars 2.55k forks source link

Using audio on the jess/pulseaudio container, with Podman and Mac OS #581

Open clementremillieux opened 2 years ago

clementremillieux commented 2 years ago

Hello,

I'm trying to use audio on the jess/pulseaudio container, launched with Podman on MacOS.

I am using a Big Sur OS with an Apple M1 chip ( also tested on an INTEL chip) I use Podman in version 3.4.4

The commmand podman run hello world works well

After launching Podman ( podman machine init and podman machine start), I connect with ssh to the VM and install pulseaudio alsa-utils pulseaudio-utils. Then I launch pulseaudio on the host Mac OS and on the podman VM with the command

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

Then I run the following command to launch the container:

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

and I get this error on my host terminal (the containers is then not launch):

{"msg": "exec container process "/usr/bin/speaker-test": Exec format error","level":"error","time":"2021-12-13T12:40:09.000532852Z"}

when I run the following command

podman run -it -e PULSE_SERVER=docker.for.mac.localhost -v /home/core/.config/pulse:/home/pulseaudio/.config/pulse --rm jess/pulseaudio

I got:

{"msg":"exec container process "/usr/bin/pulseaudio": Exec format error","level":"error","time":"2021-12-13T13:00:04.000533324Z"}

I would like to point out that the following command works for me with Docker, on the same macOS:

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.

I know that Podman uses a virtual machine on Mac OS. So I think I should first link the audio of the virtual machine with the audio of the MacOS host like when I mount volumes (first I mount the volume on the VM and then on the container) but I'm not sure. Is there some specific podman configuration or command to use audio, or should I do it manually ?

Do you have an idea?

Thanks