How to runs GUI Application in Docker?

Task :- Launch Firefox in Docker Container
👉 Step1: Configure Docker Yum Repository
[docker]
baseurl = https://download.docker.com/linux/centos/7/x86_64/stable/
gpgcheck = 0
name = docker repo

👉 Step2: Installing Docker
yum install docker-ce --nobest -y

👉 Step3: Verifying docker installation
docker info

👉 Step4: Start the docker services
systemctl start docker
systemctl status docker

👉 Step5: Create a Docker file
vim Dockerfile

FROM centos
RUN yum install firefox -y
CMD ["/usr/bin/firefox"]
👉 Step6: Build the Docker Image
docker build -t <image name> .

Docker image created successfully, you can verify it by the below command.
docker images | grep skabhi003/firefox

👉 Step7: Launch GUI application On the Docker container
docker run -it --name=os1 --net=host --env="DISPLAY" skabhi003/firefox
--net = for using host’s network
--env = for using environmet varibale(DISPLAY)

👉 At Last , Firefox will launch Successfully.

Thanks, hope you guys will like my article. if you have any suggestion or query will free to ask.