GUI Application On Docker Container

In this article I’m going to practically explain you about how to run GUI application on top of docker container.

Let’s start it….

Step 1: Checking availability of docker

First thing you required is docker installed in your system . We can check it by using command

docker version

Step 2: Install Centos Image

First we have to install docker image . You can choose any image for it. Here I’m going to install latest centos image. Command for it is

docker pull centos:latest

In my case centos image was already installed that’s why output is like this. In your case if it’s not installed already then it will download from internet. It will take some time to install image according to your network connectivity.

Step 3 :Launch container

Main step to launch GUI application on docker container is here . With run command we have to pass some parameters that gonna help us to lauch our GUI application on docker.

Command is:

docker run -it --name Task2 --net=host --env="DISPLAY" --volume="$HOME/ .Xauthority:/root/.Xauthority:rw" centos:latest

Step 4 : Install required packages inside docker container

For this practical we need install some packages/software in it. ncurses package provides clear command. Also with it I have install python3 with it using same command.

yum install python3 ncurses -y

Now , install firefox using command given below

yum install firefox -y

Next step is to install jupyter notebook. We can install with pip3 command .

pip3 install jupyter

Step 5 : Trying to launch GUI applications on Docker

Now try to open firefox using command line and check whether it open in GUI or not

To open firefox from command line just run command

firefox

hurrayyyyyyy!!!! We have done our main task that is running GUI application on top of docker container. As you can see in above image after running firefox command browser is launched inside centos continer.

That’s why it showing centos home page which is come by default OS to OS.

Now check if jupyter notebook is working in it or not.

It is not preferred to launch jupyter notebook with root account directly. So here we have to use — allow-root option with our command.

So command to launch jupyter will be like

jupyter notebook --allow-root

You can see jupyter notebook is launched successfully on docker container.

Like this we can run other application on docker container to.

Thanks for reading!!!!!!!!!!!

--

--

Get the Medium app

A button that says 'Download on the App Store', and if clicked it will lead you to the iOS App store
A button that says 'Get it on, Google Play', and if clicked it will lead you to the Google Play store