LXD container ALSA audio support

host: Ubuntu 18.04 LXD/LXC 3.0.3

I am trying to use ALSA in my ubuntu 18.04 container. ALSA on host works. I have seen this post but it doesn’t work for me.

My configuration:

lxc config set mycontainer raw.lxc "lxc.cgroup.devices.allow = c 116:* rwm"
lxc config set mycontainer raw.lxc "lxc.mount.entry = /dev/snd dev/snd none bind,optional,create=dir 0 0"

aplay: aplay -l aplay: device_list:270: no soundcards found…

ALSA on the host works perfectly well.

I need it for a home automation text-to-speech functionality.

What else do I need to do to get it working?

Thank you in advance.

Hi!
Does your host have Pulseaudio?

If the software can use Pulseaudio instead, then you can share the Pulseaudio’s Unix socket. It’s a single thing to do. See more on this at https://blog.simos.info/how-to-easily-run-graphics-accelerated-gui-apps-in-lxd-containers-on-your-ubuntu-desktop/

@simos,

Thank you for this info. I would prefer not to install pulseaudio on my host/server, it would be much simpler to use ALSA if it is possible of course.

I guess, I have managed to get it working.
Found this post

lxc config device add <container> pcmC0D2c unix-char path=/dev/snd/pcmC0D2c
I have added all devices listed in/dev/snd:

controlC0 hwC0D0 hwC0D2 pcmC0D0c pcmC0D0p pcmC0D10p pcmC0D1p pcmC0D2c pcmC0D3p pcmC0D7p pcmC0D8p pcmC0D9p seq timer

It is important to add seq and timer, as well.

1 Like