By default Docker did not provide Graphical User Interface, how to enable it we will find out in this article.

The Containerization Technology existed before 2013, but it was hard to learn and hard to implement. So, what was the major changes that took place in 2013? At the PyCon in 2013 one person demonstrated first time to use Docker tool that behind the scene uses Containerization Technology. This man was Solomon Hykes. During that conference he was given 5 minutes time to speak on his tool. At that time no one knew who is Solomon Hykes. After his dedicated efforts for another 3 years, all the industry people wanted to hear from him about Docker. Below is the link of the first talk of Solomon Hykes.

(494) The future of Linux Containers — YouTube

Use Cases

Why we need O.S. ? We need O.S. to run or execute Applications created by Developers. In this agile technology world the app that comes with new features first have the customers and future scope. To test apps we need to launch new O.S. and do the testing of the apps. In the real world we have to reduce the time that is taken by app to come up in the market, this is called Time To Market.

There are various ways to interact with Physical Hardware

  1. Installing it on your local laptops called Bare Metal
  2. By Virtualization Tool like VMware, Virtual Box
  3. By Containerization tools like Podman, CRI-O , Docker
  4. Using Cloud Computing Services like AWS, Azure or GCP

If we try to install O.S. in our laptop locally or by Virtualization Tools it takes approximately 30–45 minutes to install O.S. and login inside it.

Our need is to minimize the time for installing O.S. , so company can gain profits. As in real world we have to launch 1000’s of O.S. for testing and then terminate it.

Containerization Technology provided the solution for the above problem. By this technology we can install the O.S. , boot the O.S. and login inside it in less than 1 second.

For this practical I am using the windows as my base O.S. , on the top of it I am using the image of RHEL 8 on Virtual Box. Inside RHEL 8 O.S. I have installed Docker.

For starting an O.S. inside the Docker. Use the below command.

docker run -t -i image_name:version

In the above command docker helps us to run a container. run keyword helps to start the O.S. , -t gives the terminal and -i provides an interactive terminal.

Example
docker run -t -i ubuntu:14.04

Container by default does not provide Graphical User Interface as it makes things slower.

Vocabulary

  1. In docker world O.S. is termed as container.
  2. Docker is called Docker Engine.
  3. Here we are running Docker Engine on the top of RHEL 8, here the RHEL 8 is called Docker Host.

Some More Commands

  1. To check how many O.S. or container running on Docker Engine.
docker ps

2. exit , command to logout from the container.

3. If you want to give name to container you can do it so.

docker run -i -t --name os_name image:version

Use of ID

Docker engine provides unique ID to each container. By this ID we can start and stop the container. ID for the container we get randomly by docker engine.

Proceeding To Our Task

In the industry we do everything inside the containers. We train Machine Learning models inside containers. This is called Containerized Machine Learning Models. We do it so we can install the packages and libraries of Machine Learning as per our needs, by this way we reduce space complexity and also storage consumption is less.

Our main focus is how we can install Jupyter inside containers, but why we need to install it ? While creating machine learning models we usually use Jupyter. But the challenge here is that container we launch inside docker engine provides us CLI way to interact not the GUI way.

Few things to be noticed

  1. Jupyter Notebook needs GUI web browser like Firefox, chrome or any other.
  2. So we need to download any GUI browser first

Let’s Start

  1. Launch an container
docker run -it --name jupyter centos:latest

2. Installing python3 inside the container

yum install python3 -y

3. Installing Firefox inside container

yum install firefox -y

4. Install jupyter in the container

pip3 install jupyter

5. Now if you run jupyter-notebook command it will throw this kind of error.

No web browser found: could not locate runnable browser.

Exit from the container.

5. To solve, let’s us first make the image of this container, so we don’t need to install packages again.

Syntax
docker commit container_name image_name:tag
Saving the image
docker commit jupyter jupyter:v1

6. Now while launching the container from the image we created.

docker run -it --name jupyter --env="DISPLAY" --net=host jupyter:v1

In the above command we are using the GUI of our Docker Host.

That’s all.

Thanks For Reading.

Ex294 RedHat Certified Engineer | Ansible | Docker | Terraform | Kubernetes | MLOPS