Skip to content

Instantly share code, notes, and snippets.

@juliangaal
Created March 28, 2023 08:27
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save juliangaal/2a79e721345390021d52047d284d64ec to your computer and use it in GitHub Desktop.
Save juliangaal/2a79e721345390021d52047d284d64ec to your computer and use it in GitHub Desktop.
Docker X11 Ubuntu 20.04
FROM ubuntu:20.04
RUN apt-get update && apt-get install -y x11-apps
ARG user=julian
ARG home=/home/$user
RUN groupadd -g 1000 $user
RUN useradd -d $home -s /bin/bash -m $user -u 1000 -g 1000 \
&& echo $user:ubuntu | chpasswd \
&& adduser $user sudo
WORKDIR $home
USER $user
ENV HOME $home
COPY entrypoint.sh .
ENTRYPOINT ["./entrypoint.sh"]
#!/bin/bash
echo "DISPLAY=$DISPLAY"
xclock # x11 example application
echo "Done."
exec bash
Instructions
============
- Adapt user in Dockerfile to match yours
- build and run
chmod +x entrypoint.sh
docker build -t x11 .
docker run -v /tmp/.X11-unix:/tmp/.X11-unix -e DISPLAY=$DISPLAY -h $HOSTNAME -v $HOME/.Xauthority:/home/$USER/.Xauthority x11
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment