Skip to content

Instantly share code, notes, and snippets.

@franckverrot
Created March 15, 2026 20:24
Show Gist options
  • Select an option

  • Save franckverrot/cbaf471a4cb1c8981dc8f260d5a0aa3b to your computer and use it in GitHub Desktop.

Select an option

Save franckverrot/cbaf471a4cb1c8981dc8f260d5a0aa3b to your computer and use it in GitHub Desktop.
Running Graphical Apps in Apple's Container Tool
FROM ubuntu:24.04
ENV DEBIAN_FRONTEND=noninteractive
RUN apt-get update && apt-get install -y \
tigervnc-standalone-server novnc websockify \
fluxbox xterm dbus-x11 \
&& rm -rf /var/lib/apt/lists/*
RUN useradd -m vncuser
USER vncuser
WORKDIR /home/vncuser
# Set VNC password non-interactively
RUN mkdir -p /home/vncuser/.vnc && \
echo "mypassword" | vncpasswd -f > /home/vncuser/.vnc/passwd && \
chmod 600 /home/vncuser/.vnc/passwd && \
printf '#!/bin/sh\nexec fluxbox\n' > /home/vncuser/.vnc/xstartup && \
chmod +x /home/vncuser/.vnc/xstartup
USER root
COPY <<'EOF' /start.sh
#!/bin/sh
su - vncuser -c "vncserver :1 -geometry 1920x1080 -depth 24 -localhost no"
# Wait for VNC to actually be listening
echo "Waiting for VNC server..."
for i in $(seq 1 30); do
if [ -e /tmp/.X11-unix/X1 ]; then
echo "VNC server is ready."
break
fi
sleep 1
done
# Start websockify in foreground (keeps container alive)
exec websockify --web /usr/share/novnc 6080 localhost:5901
EOF
RUN chmod +x /start.sh
EXPOSE 5901 6080
CMD ["/start.sh"]
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment