Skip to content

Instantly share code, notes, and snippets.

@lukaszlach
Last active March 23, 2026 03:31
Show Gist options
  • Select an option

  • Save lukaszlach/08ad4a2ddf948e800ace7988f1f9bf1d to your computer and use it in GitHub Desktop.

Select an option

Save lukaszlach/08ad4a2ddf948e800ace7988f1f9bf1d to your computer and use it in GitHub Desktop.

Docker Webinar - Come get some!

Łukasz Lach, Docker Captain | 2020

https://lach.dev/ | https://github.com/lukaszlach/

X

Install X Server (Windows and Mac)

Prepare X environment (Windows and Mac)

DISPLAY=:0 xhost + 127.0.0.1
export DISPLAY=host.docker.internal:0

Try running /usr/X11/bin/xhost if simple xhost does not work for you.

Prepare X environment (Linux)

Check if you have the DISPLAY environment variable set:

env | grep DISPLAY

Set it if needed:

export DISPLAY=:0

Eyes on the first example

Windows and Mac:

docker run -e DISPLAY alpine:3 sh -c 'apk -U add xeyes && xeyes'

Linux:

docker run -e DISPLAY -v /tmp/.X11-unix:/tmp/.X11-unix alpine:3 sh -c 'apk -U add xeyes && xeyes'

Ready examples

https://github.com/jessfraz/dockerfiles

docker run -e DISPLAY jess/tor-browser
docker run -e DISPLAY jess/wireshark
docker run -e DISPLAY jess/libreoffice
docker run -e DISPLAY jess/firefox

C:\>

Dockerfile

FROM ubuntu:20.04
CMD ["dosbox"]
VOLUME /dosbox
RUN apt-get update && \
    apt-get install -y dosbox
RUN export CONF=$(dosbox -printconf) && \
    sed -i 's/^usescancodes=.*/usescancodes=false/g' "$CONF" && \
    echo 'MOUNT C /dosbox' >> "$CONF" && \
    echo 'C:' >> "$CONF"

Play it

docker build -t dosbox .
docker run -it -e DISPLAY -v $(pwd)/games:/dosbox dosbox

Parseltongue

main.py

import gi
gi.require_version("Gtk", "3.0")
from gi.repository import Gtk

window = Gtk.Window(title="Hello World")
window.set_border_width(20)
window.set_size_request(300, 150)

button1 = Gtk.Button("Hello from Docker!")
window.add(button1)

window.show_all()
window.connect("destroy", Gtk.main_quit)
Gtk.main()

Dockerfile

FROM debian:buster
CMD ["python3", "/main.py"]
RUN apt-get update && \
    apt-get install -y \
      python3-gi python3-gi-cairo gir1.2-gtk-3.0
COPY main.py /

Run it

docker build -t python-gui .
docker run -e DISPLAY python-gui

Come get some

Dockerfile

FROM debian:stretch
ENV DEBIAN_FRONTEND noninteractive
RUN apt-get update && \
    apt-get install -y curl apt-transport-https x11vnc xvfb gnupg && \
    dpkg --add-architecture i386 && \
    curl https://dl.winehq.org/wine-builds/Release.key | apt-key add - && \
    echo "deb https://dl.winehq.org/wine-builds/debian/ stretch main" > /etc/apt/sources.list.d/wine.list && \
    apt-get update && \
    apt-get install -y --allow-unauthenticated --install-recommends winehq-devel && \
    curl -o /usr/bin/winetricks https://raw.githubusercontent.com/Winetricks/winetricks/master/src/winetricks && \
    chmod +x /usr/bin/winetricks
ENV DISPLAY :1

WORKDIR /eduke3d
RUN apt-get install -y wget p7zip \
    && wget https://dukeworld.com/eduke32/synthesis/latest/eduke32_win32_20200907-9257-93f62bbad.7z \
    && 7zr x eduke32_win32_*.7z \
    && wget https://github.com/zear/eduke32/raw/master/polymer/eduke32/duke3d.grp \
    && rm -f eduke32_win32_*.7z

CMD ["bash", "/eduke32.sh"]
VOLUME /root/.wine
EXPOSE 5900/tcp
ENV WINEDLLOVERRIDES="mscoree,mshtml="
WORKDIR /
COPY eduke32.sh .

eduke32.sh

#!/usr/bin/env bash
RESOLUTION=800x600x24
DISPLAY=:1
Xvfb $DISPLAY -screen 0 $RESOLUTION &
sleep 2
x11vnc -display $DISPLAY -bg -nopw -listen 0.0.0.0 -xkb
sleep 2

cd /eduke3d
exec wine eduke32.exe

Play it

Download all the files:

curl -sSfL lach.dev/duke-nukem-3d > Dockerfile
curl -sSfL lach.dev/eduke32.sh > eduke32.sh

Build and run the game on VNC port 5900:

docker build -t duke-nukem-3d .
docker run -v $(pwd)/wine:/root/.wine -p 5900:5900 duke-nukem-3d

@thevops

thevops commented Nov 5, 2020

Copy link
Copy Markdown

I had to execute xhost local:root before starting docker with xeyes. I have Linux Mint 19 :)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment