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
Now let’s have a look on the running containers by docker ps command.It’s an empty list.
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
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.
Now build the image by using the command.This command used the Dockerfile to build a new container image.
docker build -t firefox .
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
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
And here you go!!!
We have successfully launched the firefox on the docker container.
!!Thanks for everyone!!