How to play sound in a docker container : <p>I'm trying to dockerize a text to speech application for sharing the code with other developers, however the issue I am having right now is the docker container cannot find the sound card on my host machine. </p>

<p>When I try to play a wav file in my docker container</p>

<pre><code>root@3e9ef1e869ea:/# aplay Alesis-Fusion-Acoustic-Bass-C2.wav
ALSA lib confmisc.c:768:(parse_card) cannot find card '0'
ALSA lib conf.c:4259:(_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:4259:(_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:4259:(_snd_config_evaluate) function snd_func_refer returned error: No such file or directory
ALSA lib conf.c:4738:(snd_config_expand) Evaluate error: No such file or directory
ALSA lib pcm.c:2239:(snd_pcm_open_noupdate) Unknown PCM default
aplay: main:722: audio open error: No such file or directory
</code></pre>

<p>I guess that the main problem is docker container is unable reach the sound card on my host. </p>

<p>So far I have </p>

<ol>
<li>I installed alsa-utils and most of the alsa dependencies within my
docker container. </li>
<li>Added <code>--group-add audio</code> while running the
container by specifying  <code>docker run --group-add audio -t -i
self/debian /bin/bash</code></li>
</ol>

<p>I am not sure if this is even possible with docker(I'm not exactly sure of how hardware resources such as sound cards are shared with containers). I'm using a debian container on a Mac OS Yosemite host.  </p>
