GUI Application inside Docker

Docker containers run as a process under the main operating system, you can run multiple containers on a single machine. This means that, instead of choosing the exact right size for each machine, you can simply provide a large machine and run several Docker containers on that machine. If you need more horsepower for one of your containers, you can simply move it to a new machine. Mostly container applications run in background mode but we can run foreground (GUI application) over docker container if the base os has GUI facilities.

we have many by which we can launch GUI inside Docker but here I use 2 of those in both some of the part is same or we can say almost all process is same we have a site difference at last

Follow the steps to run firefox(GUI App) on the top of docker:-

1) Create a Dockerfile that consist firefox as an application

FROM centos:latest
RUN yum install firefox -y
CMD /usr/sbin/firefox

No alt text provided for this image

2) create a Docker image with Dockerfile by using build cmd.

# go inside the folder where we have Dockerfile

docker build -t <image_name>:v1 <location-of-docker-file>

docker build -t firefox-centos:v1 .

3) After creating image now we have to write a cmd by which we can launch docker

in that cmd we use some more specification and that are

1.share the Host’s Display environment with container

--env="DISPLAY"

2. set the networking to the host driver

--net=host

— net=host option is used to make the programs inside the Docker container look like they are running on the host itself

3. share your Host’s Xserver with the container by mounting it with container volume

--volume="$HOME/.Xauthority:/root/.Xauthority:rw"

now here we have many ways to take this Xauthority we can take this and we have one more that is

  • 3.1 We need to transfer the X11 socket from Linux base OS to the container in order to run directly.
-v /tmp/.X11-unix/

4) so now launch with first one

docker run -it --net-host --env="DISPLAY" --name gui --volume="$HOME/.Xauthority:/root/.Xauthority:rw" firefox-centos:v1

4.1) lets see with second one also

docker run -it -e DISPLAY --net=host -v /tmp/.X11-unix/ firefox-centos:v1

5. lets see o/p

No alt text provided for this image

Here you can see that gedit is running in GUI mode with some warnings in the backend.

Thank You

要查看或添加评论,请登录

Gaurav Rathi的更多文章

  • Industry Use-Cases of Jenkins

    Industry Use-Cases of Jenkins

    In this article, we are going to learn about the DevOps tool and the name of that tool is Jenkins This is the main tool…

  • Research for Industry Use-Cases of Openshift

    Research for Industry Use-Cases of Openshift

    In this article we are going to learn about OpenShift and how it works and what is the need for these tools in the…

  • NETFLIX-AWS CASE STUDY

    NETFLIX-AWS CASE STUDY

    In this blog, we are going to learn how Netflix uses AWS cloud to run its business. AWS provides resources to Netflix…

  • Industry Use-Case of Neural Networks(NN)

    Industry Use-Case of Neural Networks(NN)

    What is a Neural Network? Neural networks can be taught to perform complex tasks and do not require programming as…

  • AKS-Azure Kubernetes Service

    AKS-Azure Kubernetes Service

    AKS is a good example of INFRASTRUCTURE as a Service and PLATFORM as a Service. Here as we know Azure is a public…

  • Summary of Expert Session Delivered on Kubernetes | Container | Openshift

    Summary of Expert Session Delivered on Kubernetes | Container | Openshift

    Hello Connections, “Expert session on Industry use cases of Kubernetes/OpenShift ” was one of the great sessions. Which…

  • Git and GitHub Workshop

    Git and GitHub Workshop

    What is GIT? Git is a distributed version control system for tracking changes in any set of files, originally designed…

  • ARTH - Task 14.2 ??????

    ARTH - Task 14.2 ??????

    *Task Description*?? ?? *14.2* Further in ARTH - Task 10 has to create an Ansible playbook that will retrieve new…

  • ARTH - Task 14.3 ??????

    ARTH - Task 14.3 ??????

    Task Description: Create an Ansible Playbook which Dynamically Loads Variable Filename same as OS_Name and just by…

  • ARTH - Task 17 ??????

    ARTH - Task 17 ??????

    Task Description?? ?? Create your own Chat Servers, and establish a network to transfer data using Socket Programing by…

社区洞察

其他会员也浏览了