In this article, we are going to launch a GUI application in the Docker container. According to your use case, you can run any GUI application inside docker. In my case, I am using the Firefox web browser application.
Pre-requisite: Docker should be installed in your virtual machine.
How to Install Docker on CentOS 8/RHEL 8
Docker is a tool that allows you to easily build, test and deploy applications smoothly and quickly using containers…
Create customized docker image:
Let's say we want to run any application inside the docker container process. So, first, we have to install the software. Instead of installing every time when we create a container process. We can create a customized container image that has the software. This process is called creating a customized docker image or docker build. For this, the best approach to create an image is “Dockerfile”.
The name of the Dockerfile (Default is ‘PATH/Dockerfile’) but if you want to change you can pass file name with option -f and path
RUN yum install firefox -y
RUN yum install gedit -y
To build image
docker build -tag <imagename:version> path
To run any GUI application
we need Xserver which is available in every Linux desktop environment and containers don't have it. So we need to share it from the base operating system
1.We need to run the container with the host network driver
2. We need to share the DISPLAY environmental variable to the container
3. Share hosts Xserver by creating container volume.
That all we have to do.