Mopidy Discourse

Audio device in docker

Hello,

I want to use Mopidy as a docker container, but I can not get audio output from any mopidy container I found:

This is my host audio device:

$ ls -lh /dev/snd/
total 0
drwxr-xr-x 2 root root       80 dic  7 15:35 by-path
crw-rw---- 1 root audio 116,  5 dic  7 15:35 controlC0
crw-rw---- 1 root audio 116,  9 dic  7 15:35 controlC1
crw-rw---- 1 root audio 116,  3 dic  7 15:35 pcmC0D0c
crw-rw---- 1 root audio 116,  2 dic  7 15:35 pcmC0D0p
crw-rw---- 1 root audio 116,  4 dic  7 15:35 pcmC0D1p
crw-rw---- 1 root audio 116,  6 dic  7 15:35 pcmC1D0p
crw-rw---- 1 root audio 116,  7 dic  7 15:35 pcmC1D1p
crw-rw---- 1 root audio 116,  8 dic  7 15:35 pcmC1D2p
crw-rw---- 1 root audio 116,  1 dic  7 23:41 seq
crw-rw---- 1 root audio 116, 33 dic  7 15:35 timer

# dmesg | grep bytcr
[    6.748988] bytcr_rt5651 bytcr_rt5651: quirk IN2_MAP enabled
[    6.748994] bytcr_rt5651 bytcr_rt5651: quirk realtek,jack-detect-source 1
[    6.748997] bytcr_rt5651 bytcr_rt5651: quirk realtek,over-current-threshold-microamp 2000
[    6.749000] bytcr_rt5651 bytcr_rt5651: quirk realtek,over-current-scale-factor 1
[    6.749002] bytcr_rt5651 bytcr_rt5651: quirk MCLK_EN enabled
[    6.753318] bytcr_rt5651 bytcr_rt5651: snd-soc-dummy-dai <-> media-cpu-dai mapping ok
[    6.753397] bytcr_rt5651 bytcr_rt5651: snd-soc-dummy-dai <-> deepbuffer-cpu-dai mapping ok
[    6.756230] bytcr_rt5651 bytcr_rt5651: rt5651-aif1 <-> ssp2-port mapping ok
[    6.776957] input: bytcr-rt5651 Headset as /devices/pci0000:00/808622A8:00/bytcr_rt5651/sound/card0/input5

In the host I have not ALSA or PulseAudio because I don’t need it.

How could I make a simple audio test with a container?

I will really appreciate your help.

Kind regards.

You need to make the container aware of your sound card (from this discussion for example: https://stackoverflow.com/questions/41083436/how-to-play-sound-in-a-docker-container).
Basically you have to add --device /dev/snd to your docker run / compose parameters, where /dev/snd is your soundcard peripheral (I guess this part could change to /dev/snd1 or something, especially if you have multiple soundcards).

You might also find some resources here : https://github.com/mviereck/x11docker , but it seems they mainly plug the container to an existing alsa/pulseaudio.