shairport-sync-docker icon indicating copy to clipboard operation
shairport-sync-docker copied to clipboard

user `shairport-sync` not in group `audio` in docker image

Open yrzr opened this issue 4 years ago • 8 comments

As described, which causes problems like

ALSA lib confmisc.c:767:(parse_card) cannot find card '0'
ALSA lib conf.c:4745:(_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:4745:(_snd_config_evaluate) function snd_func_concat returned error: No such file or directory
ALSA lib confmisc.c:1246:(snd_func_refer) error evaluating name
ALSA lib conf.c:4745:(_snd_config_evaluate) function snd_func_refer returned error: No such file or directory
ALSA lib conf.c:5233:(snd_config_expand) Evaluate error: No such file or directory
ALSA lib pcm.c:2660:(snd_pcm_open_noupdate) Unknown PCM sysdefault

Fixed by simply add the user to the group and restart the container.

The docker commands I am using:

docker run \
  --detach \
  --net host \
  --restart always \
  --name shairport-sync \
  --device /dev/snd \
  mikebrady/shairport-sync:3.3.8

yrzr avatar Aug 30 '21 08:08 yrzr

Thanks for the post. This is not a problem that has arisen before. Can you tell us something about the host, please?

mikebrady avatar Aug 30 '21 21:08 mikebrady

@mikebrady hi, I am running it on Gentoo Linux from an RPi4

% uname -a
Linux rpi4-de 5.10.60-v8-yrzr-ge4cb65cf23c7 #10 SMP Sat Aug 28 13:30:19 HKT 2021 aarch64 GNU/Linux
% cat /proc/asound/cards 
 0 [ALSA           ]: bcm2835_alsa - bcm2835 ALSA
                      bcm2835 ALSA
 1 [vc4hdmi0       ]: vc4-hdmi - vc4-hdmi-0
                      vc4-hdmi-0
 2 [vc4hdmi1       ]: vc4-hdmi - vc4-hdmi-1
                      vc4-hdmi-1
%  aplay -l
**** List of PLAYBACK Hardware Devices ****
card 0: ALSA [bcm2835 ALSA], device 0: bcm2835 ALSA [bcm2835 ALSA]
  Subdevices: 7/7
  Subdevice #0: subdevice #0
  Subdevice #1: subdevice #1
  Subdevice #2: subdevice #2
  Subdevice #3: subdevice #3
  Subdevice #4: subdevice #4
  Subdevice #5: subdevice #5
  Subdevice #6: subdevice #6
card 0: ALSA [bcm2835 ALSA], device 1: bcm2835 IEC958/HDMI [bcm2835 IEC958/HDMI]
  Subdevices: 1/1
  Subdevice #0: subdevice #0
card 0: ALSA [bcm2835 ALSA], device 2: bcm2835 IEC958/HDMI1 [bcm2835 IEC958/HDMI1]
  Subdevices: 1/1
  Subdevice #0: subdevice #0
card 1: vc4hdmi0 [vc4-hdmi-0], device 0: MAI PCM i2s-hifi-0 [MAI PCM i2s-hifi-0]
  Subdevices: 1/1
  Subdevice #0: subdevice #0
card 2: vc4hdmi1 [vc4-hdmi-1], device 0: MAI PCM i2s-hifi-0 [MAI PCM i2s-hifi-0]
  Subdevices: 1/1
  Subdevice #0: subdevice #0

yrzr avatar Sep 01 '21 10:09 yrzr

Thanks. Haven't tried Gentoo Linux on an RPi4. The container works when the host is Raspberry Pi OS. It might be quite a while before this gets looked at...

mikebrady avatar Sep 01 '21 17:09 mikebrady

Hi, facing the same issue, using Manjaro on a Rpi4. Have been trying things for quite a while now, The card is however seen when i "docker exec" as root into the container and execute "aplay -l" - executing "su shairport-sync -c "aplay -l"" however results in no cards found.

nettnikl avatar Oct 24 '21 15:10 nettnikl

Ah, forgot how i "solved" it in the end: Quick (after hours of trying) and dirty fix: Adjust the runscript to execute the shairport-sync as root instead of as shairport-sync, and then rebuilding the image. su-exec root shairport-sync $@

nettnikl avatar Oct 24 '21 15:10 nettnikl

Would be very interested how to get it to work without this security issue waiting to blow up. Could be that the audio group is somehow at fault here, however running as root works, and i manually added the shairport-sync user to all groups root is in, also to a group with the same gid as the audio group on the host.

nettnikl avatar Oct 24 '21 15:10 nettnikl

Thanks. Yeah, we may change the setup to execute shairport-sync as root. It's certainly simpler.

mikebrady avatar Oct 25 '21 12:10 mikebrady

Haven't forgotten this!

mikebrady avatar Nov 28 '21 15:11 mikebrady