A civil engineer with a longlife fondness for Software Libero
Link
How to Run GUI Applications in Docker (X11 Forwarding and VNC)
Learn how to run graphical applications inside Docker containers using X11 forwarding, VNC servers, and browser-based solutions for cross-platform GUI access.
Running GUI applications in Docker enables isolated desktop environments, reproducible development setups, and testing across different platforms. There are several approaches depending on your host OS and requirements.
X11 Forwarding (Linux Host)
X11 forwarding shares the host’s display server with the container, providing the best performance.
Basic X11 Forwarding
Copy# Allow container to connect to X server
xhost +local:docker
# Run GUI application
docker run -it --rm \
-e DISPLAY=$DISPLAY \
-v /tmp/.X11-unix:/tmp/.X11-unix \
firefox
Secure X11 Forwarding
Copy# More secure: allow only your local user, then run the container as that user
xhost +SI:localuser:$(id -un)
docker run -it --rm \
-e DISPLAY=$DISPLAY \
-v /tmp/.X11-unix:/tmp/.X11-unix \
--user $(id -u):$(id -g) \
firefox
Copy# Check if X socket exists
ls -la /tmp/.X11-unix/
# Verify DISPLAY variable
echo $DISPLAY
# Test X connection
xdpyinfo
# Check container logs for VNC
docker logs vnc-container
Choose X11 forwarding for best performance on Linux, VNC for cross-platform compatibility and better isolation, and noVNC for easy browser-based access without client installation. For production use cases, always secure VNC connections with strong passwords and TLS.
Nawaz Dhandala is building OneUptime with a passion for engineering reliable systems and improving observability.
This website uses cookies to improve your experience. We'll assume you're ok with this, but you can opt-out if you wish.AcceptRead More
Privacy & Cookies Policy
Privacy Overview
This website uses cookies to improve your experience while you navigate through the website. Out of these, the cookies that are categorized as necessary are stored on your browser as they are essential for the working of basic functionalities of the website. We also use third-party cookies that help us analyze and understand how you use this website. These cookies will be stored in your browser only with your consent. You also have the option to opt-out of these cookies. But opting out of some of these cookies may affect your browsing experience.
Necessary cookies are absolutely essential for the website to function properly. This category only includes cookies that ensures basic functionalities and security features of the website. These cookies do not store any personal information.
Any cookies that may not be particularly necessary for the website to function and is used specifically to collect user personal data via analytics, ads, other embedded contents are termed as non-necessary cookies. It is mandatory to procure user consent prior to running these cookies on your website.