title: run pygame with audio in docker container
body: <p>I am trying to run a pygame in a docker container but I have issues with the audio. </p>
  
  <p>This is my Dockerfile:</p>
  
  <pre><code># This explains how to enable the video: https://skandhurkat.com/post/x-forwarding-on-docker/
  
  FROM ubuntu:latest
  MAINTAINER fnndsc "dev@babymri.org"
  
  RUN apt-get update \
    &amp;&amp; apt-get install -y python3-pip python3-dev \
    &amp;&amp; cd /usr/local/bin \
    &amp;&amp; ln -s /usr/bin/python3 python \
    &amp;&amp; pip3 install --upgrade pip
  
  
  RUN apt-get update
  RUN apt-get install -qqy x11-apps
  
  RUN pip3 install pygame
  
  WORKDIR /app
  
  ADD paper_rock_scissor_game /app
  RUN python3 setup.py install
  
  ENV NAME World
  
  
  CMD ["python3", "rock_paper_scissor/run_game.py", "-w", "-d"]
  </code></pre>
  
  <p>and I run it as:
  <code>lpuggini@lpuggini-T3420:~/temporary/pygame_docker$ docker run -it -v /tmp/.X11-unix:/tmp/.X11-unix  -e DISPLAY=unix$DISPLAY --device /dev/snd --name dsgame rockpaperscissor</code></p>
  
  <p>unfortunately the game crashes due to audio issues: </p>
  
  <pre><code>lpuggini@lpuggini-T3420:~/temporary/pygame_docker$ docker run -it -v /tmp/.X11-unix:/tmp/.X11-unix  -e DISPLAY=unix$DISPLAY --device /dev/snd  rockpaperscissor
  pygame 1.9.6
  Hello from the pygame community. https://www.pygame.org/contribute.html
  Traceback (most recent call last):
    File "rock_paper_scissor/run_game.py", line 61, in &lt;module&gt;
      pygame.mixer.init()
  pygame.error: No available audio device
  lpuggini@lpuggini-T3420:~/temporary/pygame_docker$ 
  </code></pre>
  
  <p>Do you know how can I fix it?   The host machine is ubuntu. </p>
  
  <p>A couple of references: </p>
  
  <p><a href="https://stackoverflow.com/questions/41083436/how-to-play-sound-in-a-docker-container">How to play sound in a docker container</a></p>
  
  <p><a href="https://skandhurkat.com/post/x-forwarding-on-docker/" rel="nofollow noreferrer">https://skandhurkat.com/post/x-forwarding-on-docker/</a></p>
  
  <p>UPDATE:</p>
  
  <p>adding <code>RUN apt-get install -y libsdl1.2-dev libsdl-image1.2-dev libsdl-mixer1.2-dev libsdl-ttf2.0-dev</code>                                                                                                                in the Dockerfile seems to partially fix the issue. </p>
  
  <p>The laptop now outputs the sound correctly.  Still I can not find anyway to use headphones as output device. </p>