I am trying to run a pygame in a docker container but I have issues with the audio.
This is my Dockerfile:
# 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 \
&& apt-get install -y python3-pip python3-dev \
&& cd /usr/local/bin \
&& ln -s /usr/bin/python3 python \
&& 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"]
and I run it as:
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
unfortunately the game crashes due to audio issues:
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 <module>
pygame.mixer.init()
pygame.error: No available audio device
lpuggini@lpuggini-T3420:~/temporary/pygame_docker$
Do you know how can I fix it? The host machine is ubuntu.
A couple of references:
How to play sound in a docker container
https://skandhurkat.com/post/x-forwarding-on-docker/
UPDATE:
adding RUN apt-get install -y libsdl1.2-dev libsdl-image1.2-dev libsdl-mixer1.2-dev libsdl-ttf2.0-dev
in the Dockerfile seems to partially fix the issue.
The laptop now outputs the sound correctly. Still I can not find anyway to use headphones as output device.