GUI Application on Docker

📍What is Docker?

Docker is an open source platform for building, deploying, and managing containerized applications.
Docker allows to separate our applications from the infrastructure so that we can deliver software quickly.
With docker, managing infrastructure becomes similar as managing applications.
📍Why it is not preferred to run GUI applications on Docker?
Docker does not suit applications that require rich UI. Docker is mainly intended for isolated containers with console-based applications. GUI-based applications are not a priority, their support will rely on the specific case and application.
📍Can we run a GUI application on docker?
YES🤩
We need to connect the display of the Docker container with the display of Local Machine. To run GUI application XServer is required which is already available in all Linux systems.
📍What is XServer ?

XServer is a single executable (/usr/x11R6/bin/Xorg) that dynamically loads any XServer at the runtime. Some modules are automatically loaded by server where as others are optional
TASK 02 -
GUI container on the Docker
- Launch a container on docker in GUI mode
- Run any GUI software on the container
Let’s conquer the challenge………… ✈
NOTE- yum should be preconfigured on the system
Step 1- Install docker
Command: yum install docker-ce — nobest

Step 2- Check for the docker in the system
Command: docker version

Step 3- Start and enable docker services
Command to start docker service: systemctl start docker
Command to enable docker service: systemctl enable docker
Command to check the status of docker: systemctl status docker

Step 4- Pull centos image
Command: docker pull centos:latest

Step 5- Launch container
To launch GUI application on docker container we need to pass some parameters with run command.
Command: docker run — it — name <container_name> — net=host –env=”DISPLAY” –volume=”$HOME./Xauthority:/root/.Xauthority:rw” centos:latest
Here,
- By sharing volume we can share host’s XServer, volume parameter is used
- env parameter is used to share host display environment to the container
- to run the container we need to provide net parameter

Step6- Install the required packages
- Check for python3 since it is not available install it.
Command: yum install python3

Check whether for python3 now -

- Check for Firefox application as it is not available install it
Command: yum install firefox

Check for Firefox now -

It successfully launches the GUI application — Firefox

- Install jupyter
Command: pip3 install jupyter

Since we successfully installed jupyter, now run the jupyter notebook.

As this command runs on the terminal a tab of jupyter notebook opens in the browser.

Thus, we successfully launched a GUI application on Docker. Similarly as per the requirement arises we can install the application and run it on the Docker container.
Hope you enjoyed reading!😎
Do try yourself.
Keep Learning! Keep Sharing!
Stay Safe😷