Skip to content
geeksforgeeks
  • Courses
    • DSA to Development
    • Get IBM Certification
    • Newly Launched!
      • Master Django Framework
      • Become AWS Certified
    • For Working Professionals
      • Interview 101: DSA & System Design
      • Data Science Training Program
      • JAVA Backend Development (Live)
      • DevOps Engineering (LIVE)
      • Data Structures & Algorithms in Python
    • For Students
      • Placement Preparation Course
      • Data Science (Live)
      • Data Structure & Algorithm-Self Paced (C++/JAVA)
      • Master Competitive Programming (Live)
      • Full Stack Development with React & Node JS (Live)
    • Full Stack Development
    • Data Science Program
    • All Courses
  • Tutorials
    • Data Structures & Algorithms
    • ML & Data Science
    • Interview Corner
    • Programming Languages
    • Web Development
    • CS Subjects
    • DevOps And Linux
    • School Learning
  • Practice
    • Build your AI Agent
    • GfG 160
    • Problem of the Day
    • Practice Coding Problems
    • GfG SDE Sheet
  • Contests
    • Accenture Hackathon (Ending Soon!)
    • GfG Weekly [Rated Contest]
    • Job-A-Thon Hiring Challenge
    • All Contests and Events
  • DevOps Lifecycle
  • DevOps Roadmap
  • Docker Tutorial
  • Kubernetes Tutorials
  • Amazon Web Services [AWS] Tutorial
  • AZURE Tutorials
  • GCP Tutorials
  • Docker Cheat sheet
  • Kubernetes cheat sheet
  • AWS interview questions
  • Docker Interview Questions
  • Ansible Interview Questions
  • Jenkins Interview Questions
Open In App
Next Article:
How To Build Docker Image In GitHub Actions ?
Next article icon

How to Run GUI Based Applications inside Docker?

Last Updated : 04 Jan, 2025
Comments
Improve
Suggest changes
Like Article
Like
Report

A Docker Container is an isolated application platform that contains everything needed to run an application built from one or more images. Docker is an Open Source project that provides an open platform to run any number of applications inside a container according to your requirements and you can also save that environment for future use also as an image of a lightweight container.

We can easily run the most common GUI applications without getting into trouble inside a Docker Container. To run GUI Applications inside a Docker Container only need to follow a few very simple steps which are provided below. 

Table of Content

  • What is Docker?
  • What Are Docker GUI Containers?
  • How to Run GUI-Based Applications Inside the Docker? A Step-By-Step Guide
  • Docker vs Linux Containers: What are Differences?
  • Advantages of Docker Containers
  • Docker GUI Containers - FAQs


What is Docker?

Docker is container platform that helps in packaging an application with all its dependencies into a single entity. It facilitates the developers to build, ship and run the applications in any system that supports docker. It helps in simplifying the process of deployment and management of the applications by creating abstraction to the infrastructure details and making easy of container creation, deployment. It streamlines the development to production workflow on improving the scalability and reliability of the application.

What Are Docker GUI Containers?

Docker GUI Containers are the docker containers that includes the graphical user interface (GUI) components facilitating users to run and interact wwith GUI-based applications within isolated environments. These containers comes with encapsulating both the applciation and its graphical interface depedencies providing consistent deployment across the various platforms.
These containers streamlines the development, testing and deployment of GUI applications with maintaining portability and scalability.

How to Run GUI-Based Applications Inside the Docker? A Step-By-Step Guide

The following are the steps to run a GUI based application inside Docker:

Step 1: Install and Start Docker

  • Install the docker software with the following command in the Redhat Operating System:
yum install docker -y
  • Start the Docker service and check the status and restart the service to be it updated with configurations. The Systemctl commands are used to manage system services.
systemctl start docker            // to start the docker service.
systemctl status docker // to check the status .
systemctl restart docker // to restart the service.
Starting the Docker Service

Step 2: Run a Docker Container with Centos Image

  • Now pull an image from DockerHub to base OS Rhel and launch a container and install python3 inside the container. Here we are using the Docker Image as Centos because it comes with graphical drivers in it.
docker run -it — name os_name centos:latest         
Run a Centos Docker Container
  • To run docker container, (-it means interactive terminal, "os_name" you can give according to you easy to remember and "centos: latest" will give you container of centos with the latest version of centos.
  • To install python3 inside the docker container you can choose any version of python, "yum" is used for installing, deleting, and querying software packages.
yum install python3                             

Step 3: Install the GUI Softwares

  • Install the of GUI Application softwares inside container here we are going to install firefox, jupyter & gedit.
yum install firefox -y             // to install firefox 
pip3 install jupyter // to install jupyter
yum install gedit -y // to install gedit
  • The following screenshot shows the installation of Firefox software.
Install the Firefox GUI Softwares
  • The following screenshot shows the installation of gedit GUI software:
Gedit GUI Softwares
  • The following screenshot shows the installation of jupyter GUI Software:
Jupyter Software Installation

Step 4: Create Custom Image from Docker Container

  • Now create an image from the previously launched container and then launch a container of this newly created image(Inside baseOS).
  • Enter ctrl+p+q to come out of the container and make it running or run exit command to stop and come out of it.
  • Create an custom image from the docker container that we used till now with the following command:
docker commit  <container_name>   <image_name>:<version_tag>      

Example:

docker commit os1 img1:v1
creating custom docker image
  • To create an image from your running container,"os_name" is your own os you are going to create so give it a name according to you, "image_name" is the image of your own OS
  • Here, we are going to create so here also give according to you and "version" suppose it's your first image so give version as v1 or whatever we want to give. The "commit" command is used to create an image from your running container.
docker run -it --name container_name --env=”Display” -- net=host image_name:version    
Running a New GUI Container
  • To run a new docker container from your created os image in which you already install some GUI applications and env displays the environment that it received from its parent(base os), and set image name and version as you mentioned in the previous command. This is your new docker container so give a new name to this os.

 Step 5: Run the GUI Softwares In Container

  • Now here you can check by using the given commands:
firefox                            // to run firefox inside the docker
jupyter notebook // to run jupyter inside the docker
gedit // to run gedit inside the docker
exit                              // to exit from the container
  • The following screenshot shows successful launch and access of firefox GUI from the Container:
Successful Launch of GUI Firefox from Container
  • The following screenshot illustrates the success launch of jupyter notebook GUI:
  • The following screenshot is running GUI Jupyter Notebook
Running GUI Jupyter Notebook
  • Finally we have success run the GUI Based Applications inside the Docker Containers in detailing step by step.

Docker vs Linux Containers: What are Differences?

The following is the differences between Docker Containers and Linux Containers:

Aspect

Docker Containers

Linux Containers (LXC/LXD)

Management Platform

Docker is container management platform that is used for building, deploying and managing the applications using containers.

Linux Containers provides the lower-level containerization technology that is native to the Linux Kernel

Tooling

It provides the a wide set of tools and APIs for container management and deployment.

It offers more flexibility but requires manual configuration using system tools and libraries

Abstraction Level

Docker Containers add a extra layer of abstraction over the Linux container technologies with simplifying container managment and deployment.

It provides a lower-level approach to containerization and offers more control and flexibility but requires manual configuration.

Portability

These are high portable and can run the containers consistently across different environments.

These are also portable but requires more manual configuration to ensure the comptability cross different environments.

Advantages of Docker Containers

The following are the advantages of Docker Containers:

  • Portability: Docker will encapsulates its containers' applications and their dependencies making them high portable across different environments.
  • Consistency: It ensure the consistent runtime environments for applications regardless of underlying infrastructure.
  • Efficiency: These comes as light weight containers and use shared operating system resources facilitating efficient resource utilization, faster startup times and scalability.
  • Isolation: It provides the isolated environments for applications ensuring each applciation running independently without any interference from the other containers facilitating with security and stability.

The following are the articles people also refered for :-

Article Name

Article Link

Installation of Docker on Ubuntu

Read

Installation of Docker on Windows

Read

Installation of Docker on MacOS

Read


Next Article
How To Build Docker Image In GitHub Actions ?
author
lovelyshrivas04
Improve
Article Tags :
  • Technical Scripter
  • Linux-Unix
  • Docker
  • DevOps
  • Docker Container

Similar Reads

  • How To Build Docker Image In GitHub Actions ?
    GitHub Actions is a powerful tool provided by GitHub to automate tasks directly within your repositories. It plays a crucial role in Continuous Integration/Continuous Deployment (CI/CD) pipelines, enabling developers to automate workflows, tests, and deployments seamlessly. With GitHub Actions, work
    5 min read
  • Running GUI Applications on Docker in Linux
    Let's say you are trying to build a UI application and deploying it as a Docker Container. If you want that UI application to display the user interface on your local machine while running the application inside the Docker Container, you will have to connect the display of the Docker Container with
    3 min read
  • How To Use Docker For IoT Applications?
    Docker is a super tool that makes our lives much less complicated by providing us with standardization, productivity, performance, maintainability, and compatibility of our code. It lets us continuously and hastily install and test our code, and it is platform-impartial. Docker provides the ability
    8 min read
  • How to Dockerize a Django Application?
    Docker is a set of platform-as-a-service products that use OS-level virtualization to deliver software in packages called containers(namespace). To understand this perspective in a detailed way let's do a quick comparison between the virtual machines and containers: Imagine virtualization as a lock
    6 min read
  • Docker Compose for Node.js Applications
    Docker Compose is a powerful tool that facilitates managing multi-container Docker applications. While developing Node.js applications, it usually gets to a point where you need to interact with services such as a database, message broker, or cache system. Manually handling these services can be qui
    6 min read
  • How to Use Docker Images For Scaling Applications?
    Docker image is a lightweight piece of software that includes everything that your application needs to run, it includes code, software packages, and libraries. Docker images are built using a Docker file which includes the instruction for creating the image. The Docker image is built on top of a ba
    4 min read
  • How do I use Docker with GitHub Actions?
    Docker packages all the components required for software into containers, much like a recipe box. By automating chores in your development workflow, GitHub Actions serves as your personal chef. When combined, they optimize software development by effectively packaging applications and smoothly autom
    5 min read
  • How to Deploy a Go Web Application with Docker?
    Pre-requisite: Docker A popular containerization tool called Docker enables developers to quickly package programs and their environments, enabling shorter iteration times and greater resource efficiency while delivering the same intended environment each time. A container orchestration tool called
    3 min read
  • How to Dockerize a Golang Application?
    Docker is a containerization platform that lets you build, run, and manage applications in an isolated environment. In a container, software, libraries, and configuration files are bundled together and isolated from one another. Golang is an open-source, procedural, and statically typed programming
    4 min read
  • How to use Prometheus to Monitor Docker Containerized Applications
    Containerization has transformed software development by providing portability and consistency through platforms like Docker. Yet ensuring the health of those containerized applications requires monitoring. Prometheus is a monitoring tool that uses its powerful features to monitor the application an
    7 min read
geeksforgeeks-footer-logo
Corporate & Communications Address:
A-143, 7th Floor, Sovereign Corporate Tower, Sector- 136, Noida, Uttar Pradesh (201305)
Registered Address:
K 061, Tower K, Gulshan Vivante Apartment, Sector 137, Noida, Gautam Buddh Nagar, Uttar Pradesh, 201305
GFG App on Play Store GFG App on App Store
Advertise with us
  • Company
  • About Us
  • Legal
  • Privacy Policy
  • In Media
  • Contact Us
  • Advertise with us
  • GFG Corporate Solution
  • Placement Training Program
  • Languages
  • Python
  • Java
  • C++
  • PHP
  • GoLang
  • SQL
  • R Language
  • Android Tutorial
  • Tutorials Archive
  • DSA
  • Data Structures
  • Algorithms
  • DSA for Beginners
  • Basic DSA Problems
  • DSA Roadmap
  • Top 100 DSA Interview Problems
  • DSA Roadmap by Sandeep Jain
  • All Cheat Sheets
  • Data Science & ML
  • Data Science With Python
  • Data Science For Beginner
  • Machine Learning
  • ML Maths
  • Data Visualisation
  • Pandas
  • NumPy
  • NLP
  • Deep Learning
  • Web Technologies
  • HTML
  • CSS
  • JavaScript
  • TypeScript
  • ReactJS
  • NextJS
  • Bootstrap
  • Web Design
  • Python Tutorial
  • Python Programming Examples
  • Python Projects
  • Python Tkinter
  • Python Web Scraping
  • OpenCV Tutorial
  • Python Interview Question
  • Django
  • Computer Science
  • Operating Systems
  • Computer Network
  • Database Management System
  • Software Engineering
  • Digital Logic Design
  • Engineering Maths
  • Software Development
  • Software Testing
  • DevOps
  • Git
  • Linux
  • AWS
  • Docker
  • Kubernetes
  • Azure
  • GCP
  • DevOps Roadmap
  • System Design
  • High Level Design
  • Low Level Design
  • UML Diagrams
  • Interview Guide
  • Design Patterns
  • OOAD
  • System Design Bootcamp
  • Interview Questions
  • Inteview Preparation
  • Competitive Programming
  • Top DS or Algo for CP
  • Company-Wise Recruitment Process
  • Company-Wise Preparation
  • Aptitude Preparation
  • Puzzles
  • School Subjects
  • Mathematics
  • Physics
  • Chemistry
  • Biology
  • Social Science
  • English Grammar
  • Commerce
  • World GK
  • GeeksforGeeks Videos
  • DSA
  • Python
  • Java
  • C++
  • Web Development
  • Data Science
  • CS Subjects
@GeeksforGeeks, Sanchhaya Education Private Limited, All rights reserved
We use cookies to ensure you have the best browsing experience on our website. By using our site, you acknowledge that you have read and understood our Cookie Policy & Privacy Policy
Lightbox
Improvement
Suggest Changes
Help us improve. Share your suggestions to enhance the article. Contribute your expertise and make a difference in the GeeksforGeeks portal.
geeksforgeeks-suggest-icon
Create Improvement
Enhance the article with your expertise. Contribute to the GeeksforGeeks community and help create better learning resources for all.
geeksforgeeks-improvement-icon
Suggest Changes
min 4 words, max Words Limit:1000

Thank You!

Your suggestions are valuable to us.

What kind of Experience do you want to share?

Interview Experiences
Admission Experiences
Career Journeys
Work Experiences
Campus Experiences
Competitive Exam Experiences