Gst-launch-1.0 -vv alsasrc ! alsasink does not work in docker

Hi

My docker image is based on nvcr.io/nvidia/l4t-base:r32.5.0.
But I met alsasrc/alsasink issue after running my docker image while it works fine under host env.

The log is as follow:
root@localhost:/usr/bin# GST_DEBUG=3 gst-launch-1.0 -vv alsasrc ! alsasink
0:00:00.193269296 13 0x55a5d73070 WARN ladspa gstladspa.c:507:plugin_init: no LADSPA plugins found, check LADSPA_PATH
0:00:00.993717622 13 0x55a5d73070 WARN default gstsf.c:98:gst_sf_create_audio_template_caps: format 0x120000: ‘AVR (Audio Visual Research)’ is not mapped
0:00:00.993787094 13 0x55a5d73070 WARN default gstsf.c:98:gst_sf_create_audio_template_caps: format 0x180000: ‘CAF (Apple Core Audio File)’ is not mapped
0:00:00.993824246 13 0x55a5d73070 WARN default gstsf.c:98:gst_sf_create_audio_template_caps: format 0x100000: ‘HTK (HMM Tool Kit)’ is not mapped
0:00:00.993987030 13 0x55a5d73070 WARN default gstsf.c:98:gst_sf_create_audio_template_caps: format 0xc0000: ‘MAT4 (GNU Octave 2.0 / Matlab 4.2)’ is not mapped
0:00:00.994109078 13 0x55a5d73070 WARN default gstsf.c:98:gst_sf_create_audio_template_caps: format 0xd0000: ‘MAT5 (GNU Octave 2.1 / Matlab 5.0)’ is not mapped
0:00:00.994137878 13 0x55a5d73070 WARN default gstsf.c:98:gst_sf_create_audio_template_caps: format 0x210000: ‘MPC (Akai MPC 2k)’ is not mapped
0:00:00.994172502 13 0x55a5d73070 WARN default gstsf.c:98:gst_sf_create_audio_template_caps: format 0xe0000: ‘PVF (Portable Voice Format)’ is not mapped
0:00:00.994210134 13 0x55a5d73070 WARN default gstsf.c:98:gst_sf_create_audio_template_caps: format 0x160000: ‘SD2 (Sound Designer II)’ is not mapped
0:00:00.994239670 13 0x55a5d73070 WARN default gstsf.c:98:gst_sf_create_audio_template_caps: format 0x190000: ‘WVE (Psion Series 3)’ is not mapped
0:00:01.280365436 13 0x55a5d73070 WARN omx gstomx.c:2826:plugin_init: Failed to load configuration file: Valid key file could not be found in search dirs (searched in: /root/.config:/etc/xdg as per GST_OMX_CONFIG_DIR environment variable, the xdg user config directory (or XDG_CONFIG_HOME) and the system config directory (or XDG_CONFIG_DIRS)
Setting pipeline to PAUSED …
0:00:01.558535840 12 0x5574586400 WARN alsa pcm_hw.c:1602:snd_pcm_hw_open: alsalib error: open ‘/dev/snd/pcmC0D0p’ failed (-2): No such file or directory
0:00:01.558731904 12 0x5574586400 WARN alsa gstalsasink.c:848:gst_alsasink_open: Error -2 (No such file or directory) calling snd_pcm_open (&alsa->handle, alsa->device, SND_PCM_STREAM_PLAYBACK, SND_PCM_NONBLOCK)
0:00:01.558785280 12 0x5574586400 WARN alsa gstalsasink.c:865:gst_alsasink_open: error: Could not open audio device for playback.
0:00:01.558807104 12 0x5574586400 WARN alsa gstalsasink.c:865:gst_alsasink_open: error: Playback open error on device ‘default’: No such file or directory
ERROR: Pipeline doesn’t want to pause.
ERROR: from element /GstPipeline:pipeline0/GstAlsaSink:alsasink0: Could not open audio device for playback.
Additional debug info:
gstalsasink.c(865): gst_alsasink_open (): /GstPipeline:pipeline0/GstAlsaSink:alsasink0:
Playback open error on device ‘default’: No such file or directory
Setting pipeline to NULL …
Freeing pipeline …

I also tried the pipeline under official image.
Similar issue seen:
eswin@localhost:~/edk$ sudo docker run -it --rm --net=host --runtime nvidia -e DISPLAY=$DISPLAY -v /tmp/.X11-unix/:/tmp/.X11-unix -v /dev/:/dev/ nvcr.io/nvidia/l4t-base:r32.5.0
[sudo] password for eswin:
root@localhost:/#
root@localhost:/# GST_DEBUG=3 gst-launch-1.0 -vv alsasrc ! alsasink
0:00:00.104117858 11 0x55b9335070 WARN ladspa gstladspa.c:507:plugin_init: no LADSPA plugins found, check LADSPA_PATH
0:00:00.695994369 11 0x55b9335070 WARN default gstsf.c:98:gst_sf_create_audio_template_caps: format 0x120000: ‘AVR (Audio Visual Research)’ is not mapped
0:00:00.696061921 11 0x55b9335070 WARN default gstsf.c:98:gst_sf_create_audio_template_caps: format 0x180000: ‘CAF (Apple Core Audio File)’ is not mapped
0:00:00.696093505 11 0x55b9335070 WARN default gstsf.c:98:gst_sf_create_audio_template_caps: format 0x100000: ‘HTK (HMM Tool Kit)’ is not mapped
0:00:00.696128833 11 0x55b9335070 WARN default gstsf.c:98:gst_sf_create_audio_template_caps: format 0xc0000: ‘MAT4 (GNU Octave 2.0 / Matlab 4.2)’ is not mapped
0:00:00.696171969 11 0x55b9335070 WARN default gstsf.c:98:gst_sf_create_audio_template_caps: format 0xd0000: ‘MAT5 (GNU Octave 2.1 / Matlab 5.0)’ is not mapped
0:00:00.696221441 11 0x55b9335070 WARN default gstsf.c:98:gst_sf_create_audio_template_caps: format 0x210000: ‘MPC (Akai MPC 2k)’ is not mapped
0:00:00.696244737 11 0x55b9335070 WARN default gstsf.c:98:gst_sf_create_audio_template_caps: format 0xe0000: ‘PVF (Portable Voice Format)’ is not mapped
0:00:00.696267905 11 0x55b9335070 WARN default gstsf.c:98:gst_sf_create_audio_template_caps: format 0x160000: ‘SD2 (Sound Designer II)’ is not mapped
0:00:00.696295617 11 0x55b9335070 WARN default gstsf.c:98:gst_sf_create_audio_template_caps: format 0x190000: ‘WVE (Psion Series 3)’ is not mapped
0:00:00.867852283 11 0x55b9335070 WARN omx gstomx.c:2826:plugin_init: Failed to load configuration file: Valid key file could not be found in search dirs (searched in: /root/.config:/etc/xdg as per GST_OMX_CONFIG_DIR environment variable, the xdg user config directory (or XDG_CONFIG_HOME) and the system config directory (or XDG_CONFIG_DIRS)
Setting pipeline to PAUSED …
0:00:01.088601559 10 0x557b750aa0 WARN alsa confmisc.c:767:parse_card: alsalib error: cannot find card ‘0’
0:00:01.088691415 10 0x557b750aa0 WARN alsa conf.c:4528:_snd_config_evaluate: alsalib error: function snd_func_card_driver returned error: No such file or directory
0:00:01.088768535 10 0x557b750aa0 WARN alsa confmisc.c:392:snd_func_concat: alsalib error: error evaluating strings
0:00:01.088798551 10 0x557b750aa0 WARN alsa conf.c:4528:_snd_config_evaluate: alsalib error: function snd_func_concat returned error: No such file or directory
0:00:01.088823063 10 0x557b750aa0 WARN alsa confmisc.c:1246:snd_func_refer: alsalib error: error evaluating name
0:00:01.088846103 10 0x557b750aa0 WARN alsa conf.c:4528:_snd_config_evaluate: alsalib error: function snd_func_refer returned error: No such file or directory
0:00:01.088876791 10 0x557b750aa0 WARN alsa conf.c:5007:snd_config_expand: alsalib error: Evaluate error: No such file or directory
0:00:01.088904631 10 0x557b750aa0 WARN alsa pcm.c:2495:snd_pcm_open_noupdate: alsalib error: Unknown PCM default
0:00:01.088975895 10 0x557b750aa0 WARN alsa gstalsasink.c:848:gst_alsasink_open: Error -2 (No such file or directory) calling snd_pcm_open (&alsa->handle, alsa->device, SND_PCM_STREAM_PLAYBACK, SND_PCM_NONBLOCK)
0:00:01.089036791 10 0x557b750aa0 WARN alsa gstalsasink.c:865:gst_alsasink_open: error: Could not open audio device for playback.
0:00:01.089057143 10 0x557b750aa0 WARN alsa gstalsasink.c:865:gst_alsasink_open: error: Playback open error on device ‘default’: No such file or directory
ERROR: Pipeline doesn’t want to pause.
ERROR: from element /GstPipeline:pipeline0/GstAlsaSink:alsasink0: Could not open audio device for playback.
Additional debug info:
gstalsasink.c(865): gst_alsasink_open (): /GstPipeline:pipeline0/GstAlsaSink:alsasink0:
Playback open error on device ‘default’: No such file or directory
Setting pipeline to NULL …
Freeing pipeline …

Could you please help on this issue?
Thanks a lot in advance.

Hi,
It looks like alsa-related device nodes are missing. Would need to add the nodes to l4t.csv. It does not show what nodes cannot be found from the log. Could you try arecord command? See if it prints out more information about device nodes.

Hi Dane,

We tried the arecord command but failed as follow:

root@localhost:/usr/bin# arecord -r 48000 -c 2 -f S16_LE ./out.wav -v
arecord: main:788: audio open error: No such file or directory

We also tried aplay which show similar error:
root@localhost:/usr/bin# find / -name ***wav
/usr/share/sounds/alsa/Rear_Right.wav
/usr/share/sounds/alsa/Noise.wav
/usr/share/sounds/alsa/Rear_Left.wav
/usr/share/sounds/alsa/Rear_Center.wav
/usr/share/sounds/alsa/Front_Center.wav
/usr/share/sounds/alsa/Side_Left.wav
/usr/share/sounds/alsa/Front_Right.wav
/usr/share/sounds/alsa/Front_Left.wav
/usr/share/sounds/alsa/Side_Right.wav
root@localhost:/usr/bin# ./aplay /usr/share/sounds/alsa/Front_Right.wav
aplay: main:788: audio open error: No such file or directory

Hi,
Please run

$ ls /dev/snd/

And add the device to

/etc/nvidia-container-runtime/host-files-for-container.d/l4t.csv

Each device should be added like

dev, /dev/snd/pcmC0D0c

Abd then launch docker.

hi

I add the /dev/snd/* to the l4t.csv file

root@agx-desktop:/home/agx# more /etc/nvidia-container-runtime/host-files-for-container.d/l4t.csv
dev, /dev/snd/controlC0
dev, /dev/snd/controlC1
dev, /dev/snd/controlC2
dev, /dev/snd/controlC3
dev, /dev/snd/pcmC0D0c
dev, /dev/snd/pcmC0D3p
dev, /dev/snd/pcmC0D7p
dev, /dev/snd/pcmC0D8p
dev, /dev/snd/pcmC0D9p
dev, /dev/snd/pcmC1D0c
dev, /dev/snd/pcmC1D0p

but error is still exist, I check the GST_DEBUG=3 gst-launch-1.0 alsasrc ! alsasink cmd.

root@agx-desktop:/usr/bin/eswin/demo/006_QtAgoraCall# GST_DEBUG=3 gst-launch-1.0 alsasrc ! alsasink
Setting pipeline to PAUSED …
0:00:00.080681085 37 0x5583725010 WARN alsa pcm_hw.c:1602:snd_pcm_hw_open: alsalib error: open ‘/dev/snd/pcmC0D0p’ failed (-2): No such file or directory
0:00:00.080898322 37 0x5583725010 WARN alsa gstalsasink.c:848:gst_alsasink_open: Error -2 (No such file or directory) calling snd_pcm_open (&alsa->handle, alsa->device, SND_
PCM_STREAM_PLAYBACK, SND_PCM_NONBLOCK)
0:00:00.080964889 37 0x5583725010 WARN alsa gstalsasink.c:865:gst_alsasink_open: error: Could not open audio device for playback.
0:00:00.080995196 37 0x5583725010 WARN alsa gstalsasink.c:865:gst_alsasink_open: error: Playback open error on device ‘default’: No such file or directory
ERROR: Pipeline doesn’t want to pause.
ERROR: from element /GstPipeline:pipeline0/GstAlsaSink:alsasink0: Could not open audio device for playback.
Additional debug info:
gstalsasink.c(865): gst_alsasink_open (): /GstPipeline:pipeline0/GstAlsaSink:alsasink0:
Playback open error on device ‘default’: No such file or directory
Setting pipeline to NULL …
Freeing pipeline …

Hi,
Please check if you can see this node in docker:

$ ls -all /dev/snd/pcmC0D0p

hi

this is result, there has no pcmC0D0p device.
root@agx-desktop:/usr/bin/eswin/demo/006_QtAgoraCall# ls -all /dev/snd/pcmC0D0p
ls: cannot access ‘/dev/snd/pcmC0D0p’: No such file or directory

Hi,
Please try this command:

$ export DISPLAY=:0
$ xhost +
$ sudo docker run -it --rm --net=host --runtime nvidia --device /dev/snd -e PULSE_SERVER=unix:${XDG_RUNTIME_DIR}/pulse/native -v ${XDG_RUNTIME_DIR}/pulse/native:${XDG_RUNTIME_DIR}/pulse/native -v ~/.config/pulse/cookie:/root/.config/pulse/cookie --group-add $(getent group audio | cut -d: -f3) -e DISPLAY=$DISPLAY -v /tmp/.X11-unix/:/tmp/.X11-unix nvcr.io/nvidia/l4t-base:r32.5.0
$ apt update
$ apt install alsa-base alsa-utils pulseaudio

Reference link:
How to set ALSA default device to pulseaudio sound server on Docker? - Ask Ubuntu

1 Like

hi

$ apt update
$ apt install alsa-base alsa-utils pulseaudio ---- it should exec in docker env ?or add it into the dockerfile.

hi

we exec your cmd. and using GST_DEBUG=3 gst-launch-1.0 alsasrc ! alsasink cmd to check , the issue is still .

please help me solve this problem as soon as possible.

thanks!!!

root@agx-desktop:/home/agx# docker run -it --rm --net=host --runtime nvidia --device /dev/snd -e PULSE_SERVER=unix:${XDG_RUNTIME_DIR}/pulse/native -v ${XDG_RUNTIME_DIR}/pulse/native:${XDG_RUNTIME_DIR}/pulse/native -v ~/.config/pulse/cookie:/root/.config/pulse/cookie --group-add $(getent group audio | cut -d: -f3) -e DISPLAY=$DISPLAY -v /tmp/.X11-unix/:/tmp/.X11-unix nvcr.io/nvidia/l4t-base:r32.5.0
root@agx-desktop:/#
root@agx-desktop:/# GST_DEBUG=3 gst-launch-1.0 alsasrc ! alsasink
0:00:00.474016174 11 0x55873daad0 WARN default gstsf.c:98:gst_sf_create_audio_template_caps: format 0x120000: ‘AVR (Audio Visual Research)’ is not mapped
0:00:00.474128883 11 0x55873daad0 WARN default gstsf.c:98:gst_sf_create_audio_template_caps: format 0x180000: ‘CAF (Apple Core Audio File)’ is not mapped
0:00:00.474195222 11 0x55873daad0 WARN default gstsf.c:98:gst_sf_create_audio_template_caps: format 0x100000: ‘HTK (HMM Tool Kit)’ is not mapped
0:00:00.474234455 11 0x55873daad0 WARN default gstsf.c:98:gst_sf_create_audio_template_caps: format 0xc0000: ‘MAT4 (GNU Octave 2.0 / Matlab 4.2)’ is not mapped
0:00:00.474261624 11 0x55873daad0 WARN default gstsf.c:98:gst_sf_create_audio_template_caps: format 0xd0000: ‘MAT5 (GNU Octave 2.1 / Matlab 5.0)’ is not mapped
0:00:00.474293690 11 0x55873daad0 WARN default gstsf.c:98:gst_sf_create_audio_template_caps: format 0x210000: ‘MPC (Akai MPC 2k)’ is not mapped
0:00:00.474359261 11 0x55873daad0 WARN default gstsf.c:98:gst_sf_create_audio_template_caps: format 0xe0000: ‘PVF (Portable Voice Format)’ is not mapped
0:00:00.474427936 11 0x55873daad0 WARN default gstsf.c:98:gst_sf_create_audio_template_caps: format 0x160000: ‘SD2 (Sound Designer II)’ is not mapped
0:00:00.474507331 11 0x55873daad0 WARN default gstsf.c:98:gst_sf_create_audio_template_caps: format 0x190000: ‘WVE (Psion Series 3)’ is not mapped
0:00:00.654322377 11 0x55873daad0 WARN ladspa gstladspa.c:507:plugin_init: no LADSPA plugins found, check LADSPA_PATH
MoTTY X11 proxy: Unsupported authorisation protocol
nvbuf_utils: Could not get EGL display connection
0:00:01.014816378 11 0x55873daad0 WARN omx gstomx.c:2826:plugin_init: Failed to load configuration file: Valid key file could not be found in search dirs (searched in: /root/.config:/etc/xdg as per GST_OMX_CONFIG_DIR environment variable, the xdg user config directory (or XDG_CONFIG_HOME) and the system config directory (or XDG_CONFIG_DIRS)
Setting pipeline to PAUSED …
0:00:01.320484687 10 0x55ae6222a0 WARN alsa pcm_hw.c:1602:snd_pcm_hw_open: alsalib error: open ‘/dev/snd/pcmC0D0p’ failed (-2): No such file or directory
0:00:01.320744923 10 0x55ae6222a0 WARN alsa gstalsasink.c:848:gst_alsasink_open: Error -2 (No such file or directory) calling snd_pcm_open (&alsa->handle, alsa->device, SND_PCM_STREAM_PLAYBACK, SND_PCM_NONBLOCK)
0:00:01.320871328 10 0x55ae6222a0 WARN alsa gstalsasink.c:865:gst_alsasink_open: error: Could not open audio device for playback.
0:00:01.320907874 10 0x55ae6222a0 WARN alsa gstalsasink.c:865:gst_alsasink_open: error: Playback open error on device ‘default’: No such file or directory
ERROR: Pipeline doesn’t want to pause.
ERROR: from element /GstPipeline:pipeline0/GstAlsaSink:alsasink0: Could not open audio device for playback.
Additional debug info:
gstalsasink.c(865): gst_alsasink_open (): /GstPipeline:pipeline0/GstAlsaSink:alsasink0:
Playback open error on device ‘default’: No such file or directory
Setting pipeline to NULL …
Freeing pipeline …

Hi,
Please remove the /dev/snd/* nodes in l4t.csv. This is not required. And execute the commands in docker:

root@nvidia-desktop:/# apt update
root@nvidia-desktop:/# apt install alsa-base alsa-utils pulseaudio

We have verified it on r32.5.1. Please give it a try.

root@nvidia-desktop:/# gst-launch-1.0 alsasrc ! alsasink -ev
Setting pipeline to PAUSED ...
Pipeline is live and does not need PREROLL ...
Setting pipeline to PLAYING ...
New clock: GstAudioSrcClock
/GstPipeline:pipeline0/GstAlsaSrc:alsasrc0: actual-buffer-time = 200000
/GstPipeline:pipeline0/GstAlsaSrc:alsasrc0: actual-latency-time = 10000
Redistribute latency...
/GstPipeline:pipeline0/GstAlsaSrc:alsasrc0.GstPad:src: caps = audio/x-raw, format=(string)S16LE, layout=(string)interleaved, rate=(int)44100, channels=(int)2, channel-mask=(bitmask)0x0000000000000003
Redistribute latency...
/GstPipeline:pipeline0/GstAlsaSink:alsasink0.GstPad:sink: caps = audio/x-raw, format=(string)S16LE, layout=(string)interleaved, rate=(int)44100, channels=(int)2, channel-mask=(bitmask)0x0000000000000003
^Chandling interrupt.
Interrupt: Stopping pipeline ...
EOS on shutdown enabled -- Forcing EOS on the pipeline
Waiting for EOS...
Got EOS from element "pipeline0".
EOS received - stopping pipeline...
Execution ended after 0:00:02.343542492
Setting pipeline to PAUSED ...
Setting pipeline to READY ...
Setting pipeline to NULL ...
Freeing pipeline ...

hi

pls check the log.

root@agx-desktop:/# apt install alsa-base alsa-utils pulseaudio
Reading package lists… Done
Building dependency tree
Reading state information… Done
alsa-base is already the newest version (1.0.25+dfsg-0ubuntu5).
alsa-utils is already the newest version (1.1.3-1ubuntu1).
pulseaudio is already the newest version (1:11.1-1ubuntu7.11).
0 upgraded, 0 newly installed, 0 to remove and 69 not upgraded.
root@agx-desktop:/# apt update
Hit:1 Index of /ubuntu-ports bionic InRelease
Hit:2 Index of /ubuntu-ports bionic-updates InRelease
Hit:3 Index of /ubuntu-ports bionic-backports InRelease
Hit:4 Index of /ubuntu-ports bionic-security InRelease
Reading package lists… Done
Building dependency tree
Reading state information… Done
69 packages can be upgraded. Run ‘apt list --upgradable’ to see them.
root@agx-desktop:/# aplay -L | head -n9
MoTTY X11 proxy: Unsupported authorisation protocol
xcb_connection_has_error() returned true
Failed to read cookie file ‘/root/.config/pulse/cookie’: Is a directory
Failed to load cookie file from cookie: Is a directory
MoTTY X11 proxy: Unsupported authorisation protocol
xcb_connection_has_error() returned true
Failed to read cookie file ‘/root/.config/pulse/cookie’: Is a directory
Failed to load cookie file from cookie: Is a directory
default
Playback/recording through the PulseAudio sound server
null
Discard all samples (playback) or generate zero samples (capture)
pulse
PulseAudio Sound Server
dmix:CARD=tegrahdagalent1,DEV=3
tegra-hda-galen-t194, HDMI 0
Direct sample mixing device
root@agx-desktop:/# aplay /usr/share/sounds/alsa/Front_Center.wav
MoTTY X11 proxy: Unsupported authorisation protocol
xcb_connection_has_error() returned true
Failed to read cookie file ‘/root/.config/pulse/cookie’: Is a directory
Failed to load cookie file from cookie: Is a directory
MoTTY X11 proxy: Unsupported authorisation protocol
xcb_connection_has_error() returned true
Failed to read cookie file ‘/root/.config/pulse/cookie’: Is a directory
Failed to load cookie file from cookie: Is a directory
ALSA lib pulse.c:243:(pulse_connect) PulseAudio: Unable to connect: Access denied

aplay: main:788: audio open error: Connection refused

root@agx-desktop:/# gst-launch-1.0 alsasrc ! alsasink -ev
MoTTY X11 proxy: Unsupported authorisation protocol
nvbuf_utils: Could not get EGL display connection
Setting pipeline to PAUSED …
ERROR: Pipeline doesn’t want to pause.
ERROR: from element /GstPipeline:pipeline0/GstAlsaSink:alsasink0: Could not open audio device for playback.
Additional debug info:
gstalsasink.c(865): gst_alsasink_open (): /GstPipeline:pipeline0/GstAlsaSink:alsasink0:
Playback open error on device ‘default’: No such file or directory
Setting pipeline to NULL …
Freeing pipeline …

Hi,

It seems like this path is occupied in your environment. Please try to modify to other path for this setting:

~/.config/pulse/cookie:/root/.config/pulse/cookie

hi

I’m right ? pls check it

root@agx-desktop:/home/agx# ll /root/.config/pulse/cookie/
total 8
drwxr-xr-x 2 root root 4096 8月 12 12:20 ./
drwxr-xr-x 3 root root 4096 8月 12 12:20 …/

root@agx-desktop:/home/agx# ~/.config/pulse/cookie:/root/.config/pulse/cookie
bash: /root/.config/pulse/cookie:/root/.config/pulse/cookie: No such file or directory

Hi,
No, it should not be a directory. It should be a file like

root@nvidia-desktop:/# ll /root/.config/pulse/cookie
-rw------- 1 1000 1000 256 Jun 22 07:52 /root/.config/pulse/cookie

hi

you means I should delete the /root/.config/pulse/cookie directory and then

make a new file named cookie ?

but what’s the content for the cookie ?

hi

As using root user to start the docker, so there has the /root/.config/pulse/cookie issue.

now I change the user to start docker. the log as following:

root@agx-desktop:/# gst-launch-1.0 alsasrc ! alsasink -ev
Setting pipeline to PAUSED …
No protocol specified
xcb_connection_has_error() returned true
ERROR: Pipeline doesn’t want to pause.
ERROR: from element /GstPipeline:pipeline0/GstAlsaSink:alsasink0: Could not open audio device for playback.
Additional debug info:
gstalsasink.c(865): gst_alsasink_open (): /GstPipeline:pipeline0/GstAlsaSink:alsasink0:
Playback open error on device ‘default’: No such file or directory
Setting pipeline to NULL …
Freeing pipeline …
root@agx-desktop:/#
root@agx-desktop:/#
root@agx-desktop:/#
root@agx-desktop:/# aplay /usr/share/sounds/alsa/Front_Center.wav
No protocol specified
xcb_connection_has_error() returned true
aplay: main:788: audio open error: No such file or directory

Hi,
Attach our output for your reference:

nvidia@nvidia-desktop:~$ export DISPLAY=:0
nvidia@nvidia-desktop:~$ xhost +
access control disabled, clients can connect from any host
nvidia@nvidia-desktop:~$ sudo docker run -it --rm --net=host --runtime nvidia --device /dev/snd -e PULSE_SERVER=unix:${XDG_RUNTIME_DIR}/pulse/native -v ${XDG_RUNTIME_DIR}/pulse/native:${XDG_RUNTIME_DIR}/pulse/native -v ~/.config/pulse/cookie:/root/.config/pulse/cookie --group-add $(getent group audio | cut -d: -f3) -e DISPLAY=$DISPLAY -v /tmp/.X11-unix/:/tmp/.X11-unix nvcr.io/nvidia/l4t-base:r32.5.0
[sudo] password for nvidia:
root@nvidia-desktop:/# ll /root/.config/pulse/cookie
-rw------- 1 1000 1000 256 Jun 22 07:52 /root/.config/pulse/cookie
root@nvidia-desktop:/#

/root/.config/pulse/cookie has to be a file instead of a directory. You would need to resolve this first.

hi

As using root user to start the docker, so there has the /root/.config/pulse/cookie issue.

now I change the user to start docker. the log as following:

root@agx-desktop:/# gst-launch-1.0 alsasrc ! alsasink -ev
Setting pipeline to PAUSED …
No protocol specified
xcb_connection_has_error() returned true
ERROR: Pipeline doesn’t want to pause.
ERROR: from element /GstPipeline:pipeline0/GstAlsaSink:alsasink0: Could not open audio device for playback.
Additional debug info:
gstalsasink.c(865): gst_alsasink_open (): /GstPipeline:pipeline0/GstAlsaSink:alsasink0:
Playback open error on device ‘default’: No such file or directory
Setting pipeline to NULL …
Freeing pipeline …
root@agx-desktop:/#
root@agx-desktop:/#
root@agx-desktop:/#
root@agx-desktop:/# aplay /usr/share/sounds/alsa/Front_Center.wav
No protocol specified
xcb_connection_has_error() returned true
aplay: main:788: audio open error: No such file or directory

Hi,
Please check if it works by executing:

# apt update
# apt install alsa-base alsa-utils pulseaudio

You would need to install the packages every time of launching docker.