adapted from this
setup host
run setup_pulse.sh from the host environment, as your normal user (i.e. probably not root unless that is how your environment is set up)
- only needs to happen once (per login session)
setup_pulse.sh
#!/bin/bashset -e
# remove existing files (e.g. from prior run)rm /tmp/pulseaudio.socket && truerm /tmp/pulseaudio.client.conf && true
pactl load-module module-native-protocol-unix socket=/tmp/pulseaudio.socket
cat <<EOT >> /tmp/pulseaudio.client.confdefault-server = unix:/tmp/pulseaudio.socket# Prevent a server running in the containerautospawn = nodaemon-binary = /bin/true# Prevent the use of shared memoryenable-shm = falseEOTmodify container run command
# add to env variables-e PULSE_SERVER=/tmp/pulseaudio.socket-e PULSE_COOKIE=/tmp/pulseaudio.cookie
# add to volume mounts-v /tmp/pulseaudio.socket:/tmp/pulseaudio.socket-v /tmp/pulseaudio.client.conf:/etc/pulse/client.conf