GUI based Application inside DOCKER Container !!
✅Task Description 👩🏻💻 -
📌 GUI container on the Docker
🔅 Launch a container on docker in GUI mode
🔅 Run any GUI software on the container
What is Docker ?
Docker is a container Technology, it is simple to construct containers and container-based apps thanks to Docker, a container technology. Docker is so quick that we can launch containers (OS) with its assistance in a matter of seconds. If you want to create a single application that can run and function consistently in any environment, Docker is the perfect tool.
We’ll talk about how to execute GUI programmes within a Docker container in this article. We might need GUI applications within a Docker container if we wish to put an application on top of one that needs a user interface.
We must share the DISPLAY environment variable with the Container in order to run GUI programmes within a Docker container. The display is not attached to a new launch container. We must connect the display of baseOS.
We are going to launch Jupyter Notebook and Firefox inside Docker container.
Let’s start implementation -
First of all we need to configure Docker inside our machine. I’m using RedHat virtual machine. Let’s check that docker is configured in this system or not.
rpm -q docker
We can see that docker is not configured in this virtual machine.
First of all create a docker repository.
cd /etc/yum.repos.d
vim docker.repo
Now check the repository of docker.
yum repolist
Here, we can see that docker repository is successfully created.
Now install the docker using following command.
yum install docker-ce --nobest
Here, docker is installed successfully.
Now check the version of docker.
docker --version
Now start the service of docker.
systemctl start docker
Now check the existing images and launched containers by following command.
docker images
docker ps -a
Here, we can see that there is no docker image and docker container.
Now pull the docker image. I am pulling centos image.
docker pull centos:latest
Docker images is pulled.
Now create a workspace for our task.
Create a Dockerfile.
mkdir /Docker
cd /Docker
vim Dockerfile
Dockerfile for Jupyter Notebook.
Now create docker image.
docker build -t docker_jupyter .
Docker image for Jupyter Notebook is created.
Docker Image for Jupyter Notebook.
https://hub.docker.com/repository/docker/sheetal26/docker_jupyter
Now launch a Docker container for jupyter notebook.
— name= Assign a name to the container
— env=”DISPLAY” ( Sharing the DISPLAY environment variable to the container)
— net=host (run the OS with Host’s Network driver)
Copy the url and type in the browser.
It’s working !!
We are running Jupyter Notebook inside docker container.
In the same way we can run Firefox in docker container.
Dockerfile for Firefox.
Now create Docker Image for Firefox.
https://hub.docker.com/repository/docker/sheetal26/docker_firefox
Now launch a docker container with this docker image.
We have successfully launched Jupyter Notebook and Firefox inside Docker Container.
In the same way, we can run other GUI applications like gedit in Docker container.
Thank You for Reading the Article !!