Docker how to run GUI applications

Yes, even though Docker has no devices, we can still fool it well enough by passing through our X server info as a bind mount and setting our DISPLAY environment variable.

Step 1.) Add Permission

Grant permission to docker to use the xhost/xserver

xhost +local:docker

non-network local connections being added to access control list

If you didn't do the above you will get an error like this when trying to launch a GUI app from Docker:

Unable to init server: Could not connect: Connection refused
Error: cannot open display: :0



Step 2.) Bind Mount X server to your docker container

Here is an example of doing it to Debian 11:

The relevant portion is to add the bind mount "-v /tmp/.X11-unix/:/tmp/.X11-unix"

and set the display environment variable: "-e DISPLAY=$DISPLAY debian:11"

docker run -v /tmp/.X11-unix/:/tmp/.X11-unix -it -e DISPLAY=$DISPLAY debian:11


Tags:

docker, gui, applicationsyes, devices, server, info, bind, mount, display, variable, xhost, xserver, connections, didn, app, unable, init, container, debian, relevant, portion, quot, tmp, unix,

Latest Articles

  • Docker how to run GUI applications
  • ksoftirqd/3 Linux high cpu usage solution
  • E: The repository 'http://deb.debian.org/debian buster Release' does not have a Release file. - solution Debian 10
  • Recommended SFP+ to RJ45 Adapter Module for Switch Juniper Cisco Ubiquiti TP-Link etc...
  • Bad Power Supply Issue Story Diagnosing Troubleshooting
  • Getting started with AI (Artificial Intelligence) in Linux / Ubuntu using by deploying LLM (Language Learing Models) using Ollama LLMA
  • microk8s kubernetes how to install OpenEBS
  • Flash LSI MegaRAID 2208 to IT mode in Linux Mint/Debian/Ubuntu
  • LSI MegaRAID in Linux Ubuntu / Centos Tutorial Setup Guide megacli
  • Convert-im6.q16: attempt to perform an operation not allowed by the security policy `PDF' @ error/constitute.c/IsCoderAuthorized/413. convert-im6.q16: no images defined `pts-time.jpg' @ error/convert.c/ConvertImageCommand/3258. solution ImageMagick P
  • Apache PHP sending expires header solution cannot use cache with CDN
  • How to install virt-manager in Mint 22/Ubuntu 22
  • Infiniband Guide
  • python mysql install error: /bin/sh: 1: mysql_config: not found /bin/sh: 1: mariadb_config: not found /bin/sh: 1: mysql_config: not found mysql_config --version
  • FreePBX 17 How To Add a Trunk
  • Docker Container Onboot Policy - How to make sure a container is always running
  • FreePBX 17 How To Add Phones / Extensions and Register
  • Warning: The driver descriptor says the physical block size is 2048 bytes, but Linux says it is 512 bytes. solution
  • Cisco How To Use a Third Party SIP Phone (eg. Avaya, 3CX)
  • Cisco Unified Communication Manager (CUCM) - How To Add Phones