Cannot play sound from within docker container on TX2

I am trying to play a sound within my docker container (using nvidia container runtime) on TX2 through USB headphones.

I have tried using ALSA within my container and sharing my sound cards using --device /dev/snd. I am also running as root within my container so the problem is not with my group permissions.

If I run aplay -l on my host TX2, my USB headphones show up as an audio device and if I run aplay -l inside my container they no longer do.

Any advice would be appreciated. If I have to use pulseaudio I can as well.

Hello!

I tried the following and this worked …

$ docker pull ailispaw/alsa-utils
$ sudo usermod -aG docker $USER
$ sudo reboot

Then with aplay I can see my USB headset …

$ docker run --device /dev/snd ailispaw/alsa-utils aplay -l
...
card 2: Headset [Logitech USB Headset], device 0: USB Audio [USB Audio]
  Subdevices: 1/1
  Subdevice #0: subdevice #0

And I can run speaker-test to verify audio playback …

$ docker run --device /dev/snd ailispaw/alsa-utils speaker-test -D hw:Headset,0 -c 2 -r 48000 -F S16_LE -t sine -f 500

You could try the same docker image to see if this works for you.

Regards,
Jon