Docker GUI Applications

How to Run GUI Applications in Docker in 2025

Running GUI applications within Docker containers can be a vital capability for developers and IT professionals looking to manage software environments effortlessly. As we step into 2025, Docker has evolved to support graphical applications more efficiently. This guide will take you through a comprehensive approach to setting up and running GUI applications in Docker.

Prerequisites

Before diving into running GUI applications in Docker, ensure you have Docker installed on your system. If you haven’t installed Docker yet, you can follow this guide on docker installation in Linux Mint.

Setup and Configuration

  1. Ensure your Docker host has access to a graphical server. Most setups will work with X11.
  2. Use the -e DISPLAY=$DISPLAY to export the display, which allows the container to interact with the host’s display server.
  3. Mount the X11 Unix socket with the -v /tmp/.X11-unix:/tmp/.X11-unix to enable GUI interaction.

Creating Your Dockerfile

A Dockerfile is essential for building an image. If you’re unsure about Dockerfile provisioning, you can check out this guide on Dockerfile provisioning.


    FROM ubuntu:latest
    RUN apt-get update && apt-get install -y \
        x11-apps \
        ...
    CMD ["xeyes"]
    

Running the Docker Container

Once your Dockerfile is ready, build and run your container by executing the following commands:


    docker build -t my-gui-app .
    docker run -e DISPLAY=$DISPLAY -v /tmp/.X11-unix:/tmp/.X11-unix my-gui-app
    

Troubleshooting Tips

If you face any issues, ensure:

Using Docker Compose for Simplification

For managing multiple services, Docker Compose can be a powerful tool. You can refer to this resource to learn how to use Docker Compose to maintain data persistence and manage services seamlessly.

Conclusion

Running GUI applications in Docker containers in 2025 is a robust solution for maintaining consistency across development environments. By following the guidelines above, you can ensure a stable execution of graphical applications within containers.