IS IT POSSIBLE TO RUN GUI APPLICATION ON DOCKER CONTAINER ??

IS IT POSSIBLE TO RUN GUI APPLICATION ON DOCKER CONTAINER ??

YES !! It is possible to run GUI application on top of docker container let's continue with the term DOCKER..

What is DOCKER ?

Docker is a tool designed to make it easier to create, deploy, and run applications by using containers. Containers allow a developer to package up an application with all of the parts it needs, such as libraries and other dependencies, and deploy it as one package.

the task which we want to perform is possible with Docker file so let's learn first about docker file and then we'll proceed further....

What is Docker file ?

A Docker file is a text document that contains all the commands a user could call on the command line to assemble an image. Using docker build users can create an automated build that executes several command-line instructions in succession. This page describes the commands you can use in a Docker file it is also use for building docker images including the basic requirement of the image like environmental variables, network port, and other components.

Okay ! NOW we are going to launch GUI application on Docker in my case i'm going to launch Firefox you can launch any GUI application using this approach

First create a workspace with any name .

Then create a docker file to create container with the below configuration

vim Dockerfile 
FROM centos:latest
RUN yum install firefox -y
CMD ["/usr/bin/firefox"]


After creating the Docker file now build the docker image

 docker build -t gui-app .
No alt text provided for this image

After creating the DOCKER now launch the container with GUI application using the command below:

sudo docker run --net=host --env="DISPLAY" 
-
--volume="$HOME/.Xauthority:/root/.Xauthority:rw" gui-app

After running you can see your Firefox will launch here is the result.

No alt text provided for this image


Now to cross check open a new terminal and run #docker ps command contaIner to see docker is launched or not :

No alt text provided for this image


As you can see the container is running with the same name we have created here our required task is completed.

So, if you found this interesting let me know in the comment section...

THANK YOU







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

Sneha Singh Pal的更多文章

社区洞察

其他会员也浏览了