Docker X11 GUI setup

# Running Docker with X11 GUI Support on Ubuntu

This guide explains how to run a Docker container with GUI (X11) applications displayed on the Ubuntu host.

---

## 1. Allow X11 connections from Docker

```bash
xhost +local:docker

This command permits local Docker containers to access your X11 display.


2. Run the Docker container with X11 support

docker run -it \
  --env="DISPLAY" \
  --env="QT_X11_NO_MITSHM=1" \
  --volume="/tmp/.X11-unix:/tmp/.X11-unix:rw" \
  ubuntu:20.04

3. Inside the container: install GUI tools

apt update
apt install -y x11-apps
export QT_X11_NO_MITSHM=1

To test:

xeyes

A small GUI window should open on the host screen.


4. Revoke permissions (optional)

After exiting the container:

xhost -local:docker

Notes