GUI application in Docker container

Why Run GUI Apps in Docker?
Running a GUI program in Docker can be a useful technique when you’re evaluating a new piece of software. You can install the software in a clean container, instead of having to pollute your host with new packages.
This approach also helps you avoid any incompatibilities with other packages in your environment. If you need to temporarily run two versions of a program, you can use Docker to avoid having to remove and reinstall the software on your host.
Let's build Docker Image to run firefox inside Docker Container
Let’s create a Docker Image so whenever any container launches from this Image, run the Firefox program.
FROM centos:latest
RUN yum install firefox -y
CMD firefox
Let's build our firefox image and then run a container with the same image.
#docker build -t myfirefox:v1
#docker run -it — name firefoxos1 myfirefox:v1

Error: no DISPLAY environment variable specified — why?
You must also provide the container with a DISPLAY environment variable. This instructs X clients – your graphical programs – which X server to connect to. Set DISPLAY in the container to the value of $DISPLAY on your host.
#docker run -it — name firefoxos2 — env =”DISPLAY” — net=host myfirefox:v1
— net = host (this is purely a networking concept that connects the docker container with the base OS main network card)
This option is actually needed because after launching the container it will provide us the Firefox software in the GUI window.

Containerized graphical apps are useful when you’re evaluating software or need to run two versions of a package. You can use programs on your existing desktop without needing to touch your host’s configuration.
Thank you.