docker-pulseaudio-example icon indicating copy to clipboard operation
docker-pulseaudio-example copied to clipboard

Getting "connection refused" for pa clients

Open guss77 opened this issue 5 years ago • 0 comments

With a new Pulseaudio server (I'm currently running 13.99, but I understand this applies for version 12 and above), having the cookie is no longer sufficient to allow the Pulseaudio clients to connect.

I've worked around the problem with the same technique as described in the x11docker issue #71 - creating an anonymous one-use pulseaudio socket and mounting it instead of the primary socket.

My run script looks something like this:

DOCKERID=${RANDOM} # or some other value that makes sense, for example - a counter
pasocket=$(pactl load-module module-native-protocol-unix socket=$HOME/.config/pulse/docker-socket$DOCKERID auth-anonymous=1)
docker run ... -v $HOME/.config/pulse/zoiper-socket$DOCKERID:/home/user/.pulse.socket ...
# after run
pactl unload-module $pasocket
rm -f $HOME/.config/pulse/zoiper-socket$DOCKERID

[ user is the user name of the unprivileged user inside docker]

The /etc/pulse/client.conf has to be updated, but that is not enough for command line utilities such as pacat - these need to also have the PULSE_SERVER environment variable set to unix:/home/user/.pulse.socket. I solved this by tacking an export at the end of /home/user/.bashrc. I check that this works well for the GUI applications I'm running in the docker.

guss77 avatar Apr 13 '20 09:04 guss77