How to get soundcard (play/record sound) inside a container?

I’m looking for it for some time, but I feel there is a lot of mixed, old, incomplete data on internet :confused:

Ubuntu 25.04, LXD installed from snap, ubuntu container works, however no /dev/snd… devices

I’ve added

# Allow GPU access
lxc.cgroup2.devices.allow = c 226:* rwm
lxc.mount.entry = /dev/dri dev/dri none bind,optional,create=dir

lxc.cgroup2.devices.allow = c 81:* rwm
lxc.mount.entry = /dev/video0 dev/video0 none bind,optional,create=file

#Sound device nodes
lxc.cgroup2.devices.allow = c 116:* rwm

lxc.mount.entry = /dev/snd dev/snd none bind,optional,create=dir

to /etc/lxc/default.conf (is it container config? everyone is talking “container” config, but no one specifies its location)

but container doesn’t see it:

root@devbox1:~# ls -al /dev/
total 4
drwxr-xr-x 8 root   root        520 Nov 11 21:41 .
drwxr-xr-x 1 root   root        140 Oct 31 19:22 ..
-r--r--r-- 1 root   root         37 Nov 11 21:41 .lxc-boot-id
drwx--x--x 2 nobody nogroup      40 Nov 11 21:21 .lxd-mounts
crw------- 1 root   tty     136,   0 Nov 11 21:41 console
lrwxrwxrwx 1 root   root         11 Nov 11 21:41 core -> /proc/kcore
lrwxrwxrwx 1 root   root         13 Nov 11 21:41 fd -> /proc/self/fd
crw-rw-rw- 1 nobody nogroup   1,   7 Nov  2 18:25 full
crw-rw-rw- 1 nobody nogroup  10, 229 Nov 11 21:41 fuse
lrwxrwxrwx 1 root   root         12 Nov 11 21:41 initctl -> /run/initctl
lrwxrwxrwx 1 root   root         28 Nov 11 21:41 log -> /run/systemd/journal/dev-log
drwxr-xr-x 2 nobody nogroup      60 Nov 11 23:23 lxd
drwxrwxrwt 2 nobody nogroup      40 Nov  2 18:25 mqueue
drwxr-xr-x 2 root   root         60 Nov 11 21:41 net
crw-rw-rw- 1 nobody nogroup   1,   3 Nov  2 18:25 null
crw-rw-rw- 1 root   root      5,   2 Nov 11 23:35 ptmx
drwxr-xr-x 2 root   root          0 Nov 11 21:41 pts
crw-rw-rw- 1 nobody nogroup   1,   8 Nov  2 18:25 random
drwxrwxrwt 2 root   root         40 Nov 11 22:29 shm
lrwxrwxrwx 1 root   root         15 Nov 11 21:41 stderr -> /proc/self/fd/2
lrwxrwxrwx 1 root   root         15 Nov 11 21:41 stdin -> /proc/self/fd/0
lrwxrwxrwx 1 root   root         15 Nov 11 21:41 stdout -> /proc/self/fd/1
crw-rw-rw- 1 nobody nogroup   5,   0 Nov 11 23:35 tty
crw-rw-rw- 1 nobody nogroup   1,   9 Nov  2 18:25 urandom
crw-rw-rw- 1 nobody nogroup   1,   5 Nov  2 18:25 zero
crw------- 1 nobody nogroup  10, 249 Nov 11 20:51 zfs

What should I do ?

Hi!

This support forum has switched to supporting Incus, which is a continuation of LXD.

See Migrating from LXD - Incus documentation on how to migrate to Incus.

You have 2 choices, I recommend second one:

one, directly play sound in container:

two, play sound through host socket:

I am sorry. We don’t provide support for LXD on this forum. Please contact Canonical directly. They develop and support LXD.

This topic was automatically closed 30 days after the last reply. New replies are no longer allowed.