Run GUI Application inside Docker Container

In this blog, we will launch two GUI applications (Firefox and gedit) inside a docker container.


  1. Docker installed in the base OS (here, I am using Redhat8 as the base OS)

So, let's start our practical…

Step 1: Pull the Docker container image from DockerHub

Here, I have pulled the CentOS image.

To pull the image, use ‘docker pull <image_name>:version’ command. If the version is not specified, then by default it will pull the latest version of that image.

use the ‘docker images’ command to check the images.

Step 2: Launch Container

Now, we will use the centos image to create a new container.

Use Command: ‘docker run -it -e DISPLAY=$DISPLAY -v /tmp/.X11-unix/:/tmp/.X11-unix — name <container_name> centos’

Here, we have added an environmental variable $DISPLAY for the X11 display and mounted a volume /tmp/.X11-unix/:/tmp/.X11-unix for the X11 Unix socket as the X server is responsible for GUI.

Step 3: Launch the GUI application in the container

  • Launch Gedit

First, check whether the application/software is present or not.

As the gedit software is not installed inside the container so we will first install gedit using the yum command.

Now, run gedit.

Successfully launched the gedit software.

  • Launch firefox

First, check whether the application/software is present or not.

Install firefox using the yum command.

Now, run firefox.

Successfully launched both the GUI-based application inside a docker container.

😊Thank you for Reading😊




An enthusiast learner

Love podcasts or audiobooks? Learn on the go with our new app.

Recommended from Medium

Actors using Scala & Akka — Part 2 : AskPattern and SpawnProtocol

Sample application using Docker

Navigating the GitHub Marketplace

Screenshot of GitHub marketplace

To be you, all of you, always, in everything you do — whatever that means to you.

How Icon Solutions choose MongoDB

How to clean up Node modules from stale or unused projects with one fell swoop using BASH

How to connect an existing Active Directory to Huawei Cloud Workspaces

Learn how to add recaptcha on your web forms, Installing Google recaptcha to multiple forms on a…

Get the Medium app

A button that says 'Download on the App Store', and if clicked it will lead you to the iOS App store
A button that says 'Get it on, Google Play', and if clicked it will lead you to the Google Play store
Kriti Dubey

Kriti Dubey

An enthusiast learner

More from Medium

Mixed Kubernetes on Debian & Raspberry Pi

Network of Kubernetes Cluster

Production like Kubernetes on Raspberry Pi: Setup

GUI Applications in a Docker Container

Creating the ultimate media server with Docker, Portainer, Plex, and Ubuntu Server