Skip to content

Instantly share code, notes, and snippets.

@danielroedl
Last active October 18, 2022 15:27
Show Gist options
  • Select an option

  • Save danielroedl/247cc24d932c0982aee9e9e9ddd266cf to your computer and use it in GitHub Desktop.

Select an option

Save danielroedl/247cc24d932c0982aee9e9e9ddd266cf to your computer and use it in GitHub Desktop.
Docker Ubuntu - Use Display (X) and Audio (pulse audio)
FROM ubuntu:22.04
RUN apt-get update -y \
# needed for sound
libpulse0 libasound2 libasound2-plugins \
# to test sound with e. g. aplay <sound-file>
alsa-base \
# to test display with xterm
xterm \
&& \
rm -rf /var/lib/apt/lists/*
#!/bin/bash
docker build . --tag my-ubuntu
docker run -it --rm \
-v /tmp/.X11-unix:/tmp/.X11-unix \
-e DISPLAY=$DISPLAY \
-v /etc/alsa:/etc/alsa \
-v /usr/share/alsa:/usr/share/alsa \
-v $HOME/.config/pulse:/.config/pulse \
-v /run/user/$UID/pulse/native:/run/user/$UID/pulse/native \
-e PULSE_SERVER=unix:/run/user/$UID/pulse/native \
-u $(id -u):$(id -g) \
-v $PWD:$PWD \
-w $PWD \
my-ubuntu
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment