GUI Application via Docker

GUI Application via Docker

You should have installed docker in our base OS.

Eg: Firefox in a docker container.

Docker is already installed in my RHEL8.

To check whether it is installed or not I have used the command.

docker info
No alt text provided for this image

Now let’s have a look on the running containers by docker ps command.It’s an empty list.

No alt text provided for this image

Now there are two options either you can create your own image or you can use the any one of the image from docker hub.

docker pull centos 

No alt text provided for this image

If you want to create your own image so first you have to create a ‘Dockerfile'

? vim Dockerfile

Write this lines in the file for creating an customized image of name firefox.

  • FROM centos
  • RUN yum install firefox -y
  • CMD [“usr/bin/firefox”]

RUN and CMD are both Dockerfile instructions.

No alt text provided for this image


No alt text provided for this image

Now build the image by using the command.This command used the Dockerfile to build a new container image.

docker build -t firefox .

No alt text provided for this image

Now you can seacrh the image by using the command.Grep is a Linux / Unix command-line tool used to search for a string of characters in a specified file.

docker images | grep firefox

No alt text provided for this image

Now we have to run this container by passing an environment variable as a DISPLAY and and network as a host .

? docker run -it — name=OS1 — net=host — env=’DISPLAY’ firefox

This DISPLAY variable is used to indicate to graphical applications where to display the actual graphical user interface,

The Docker option — net=host configures the Docker container to share its network stack with the host

No alt text provided for this image

And here you go!!!

We have successfully launched the firefox on the docker container.

No alt text provided for this image

!!Thanks for everyone!!



 

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

Sampreethi Bokka的更多文章

社区洞察

其他会员也浏览了