Playing on host's pulseaudio from a container
Martin Kirchgessner, 2025-11-18
Tags : linux in_english liquidsoap
Let's say you have Pulseaudio running on your host - on a Linux desktop, you very probably do. Then you can play sound from a container, without configuring anything on the host side, by binding your pulseaudio socket.
The corresponding options are:
--security-opt label=disable -e PULSE_SERVER=unix:$XDG_RUNTIME_DIR/pulse/native -v $XDG_RUNTIME_DIR/pulse/native:$XDG_RUNTIME_DIR/pulse/native
Let's try it in a more complete example:
podman run --rm -it --security-opt label=disable \
-e PULSE_SERVER=unix:$XDG_RUNTIME_DIR/pulse/native \
-v $XDG_RUNTIME_DIR/pulse/native:$XDG_RUNTIME_DIR/pulse/native \
savonet/liquidsoap:v2.4.0 'output.pulseaudio(sine())'
That should yun with Docker too, by replacing podman
with docker
.
No need to use --privileged
:
we only disable SELinux labelling so the liquidsoap
user (default one in that image)
can access the bound socket.
Context
Liquidsoap is a bit hard to include in an automated installer (i tried) so for radiotomate I'm preparing a docker image that will be installed in podman quadlets.
Stay tuned!