1

I am using host Ubuntu 16.0.4 system to run my lxc container. I uninstalled pulseaudio as I wanted to use ALSA directly.

After uninstalling pulseaudio from the host machine, I was able to play sounds using the command like one below(on host machine):

aplay /usr/share/sounds/alsa/Rear_Right.wav

Inside the lxc container, I have installed alsa libs and alsa utils. When I use the same command as above inside the container, I get the following errors:

ALSA lib confmisc.c:768:(parse_card) cannot find card '0'
ALSA lib conf.c:4248:(_snd_config_evaluate) function snd_func_card_driver returned error: No such file or directory
ALSA lib confmisc.c:392:(snd_func_concat) error evaluating strings
ALSA lib conf.c:4248:(_snd_config_evaluate) function snd_func_concat returned error: No such file or directory
ALSA lib confmisc.c:1251:(snd_func_refer) error evaluating name
ALSA lib conf.c:4248:(_snd_config_evaluate) function snd_func_refer returned error: No such file or directory
ALSA lib conf.c:4727:(snd_config_expand) Evaluate error: No such file or directory
ALSA lib pcm.c:2239:(snd_pcm_open_noupdate) Unknown PCM default
aplay: main:654: audio open error: No such file or directory

The sound devices inside container are:

bash-4.2# ls -al /dev/snd/*
crw-rw---- 1 root   29 116,  5 Nov  1 17:21 /dev/snd/controlC0
crw-rw---- 1 root   29 116,  2 Nov  1 17:21 /dev/snd/controlC1
crw-rw---- 1 root   29 116, 10 Nov  1 17:21 /dev/snd/controlC2
crw-rw---- 1 root   29 116,  9 Nov  1 17:21 /dev/snd/hwC0D0
crw-rw---- 1 root   29 116, 13 Nov  1 17:21 /dev/snd/hwC2D0
crw-rw---- 1 root   29 116,  6 Nov  1 17:21 /dev/snd/pcmC0D3p
crw-rw---- 1 root   29 116,  7 Nov  1 17:21 /dev/snd/pcmC0D7p
crw-rw---- 1 root   29 116,  8 Nov  1 17:21 /dev/snd/pcmC0D8p
crw-rw---- 1 root   29 116,  4 Nov  1 17:21 /dev/snd/pcmC1D0c
crw-rw---- 1 root   29 116,  3 Nov  1 17:27 /dev/snd/pcmC1D0p
crw-rw---- 1 root   29 116, 11 Nov  1 17:21 /dev/snd/pcmC2D3p
crw-rw---- 1 root   29 116, 12 Nov  1 17:21 /dev/snd/pcmC2D7p
crw-rw---- 1 root   29 116,  1 Nov  1 17:21 /dev/snd/seq
crw-rw---- 1 root   29 116, 33 Nov  1 17:21 /dev/snd/timer

/dev/snd/by-id:
total 0
drwxr-xr-x 2 root root  60 Nov  1 17:21 .
drwxr-xr-x 4 root root 360 Nov  1 17:21 ..
lrwxrwxrwx 1 root root  12 Nov  1 17:21 usb-126c_4.1_amplifier-00 -> ../controlC1

/dev/snd/by-path:
total 0
drwxr-xr-x 2 root root 100 Nov  1 17:21 .
drwxr-xr-x 4 root root 360 Nov  1 17:21 ..
lrwxrwxrwx 1 root root  12 Nov  1 17:21 pci-0000:00:03.0 -> ../controlC0
lrwxrwxrwx 1 root root  12 Nov  1 17:21 pci-0000:00:14.0-usb-0:5:1.0 -> ../controlC1
lrwxrwxrwx 1 root root  12 Nov  1 17:21 pci-0000:01:00.1 -> ../controlC2
  • I guess aplay -l does not work either? What is group 29? Is your user member of that group? – CL. Nov 2 '16 at 7:56
  • 29 is audio group number on host Ubuntu system. And yes, aplay -l does not work. it returns with an error: aplay: device_list:235: no soundcards found... – Monku Nov 2 '16 at 17:14
  • And what is group 29 inside the container (apparently, none), and what about the user inside the container? – CL. Nov 2 '16 at 18:20
2

I was able to play sounds finally inside the lxc container.

First, I have to make sure that lxc device cgroup is enabled for sound devices. You can do this by adding the following in the container config file:

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

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

Next, since I am using ALSA on host system to play sounds and want to use the alsa again inside the lxc container, make sure that the alsa configuration file is copied inside the container.

I copied the alsa config file from host at location /etc/asound.conf inside the lxc container. The reason for doing this is because the alsalib inside the container has to have the same configration to use as the host machine.

After this , I was able to play sounds inside the container. I tested this by running the following :

aplay /usr/share/sounds/alsa/Rear_Right.wav
  • Would you accept you own answer as that what worked for you. That will help others find this solution. – user.dz Dec 7 '16 at 11:57

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.