Building GUI Container On The Docker..

Hello All..!!

Here in this article we are going to see very interesting thing about docker. Docker is the best tool you can use if you want to develop one single application that can run and work uniformly at any environment, laptop or public cloud instance. Have you ever seen any GUI application running on docker container….??

If not…then let’s see how to build it..

Let’s say you are trying to build a UI application and deploying it as a Docker Container. If you want that UI application to display the user interface on your local machine while running the application inside the Docker Container, you will have to connect the display of the Docker Container with the display of your local machine. Let’s suppose you want to run Mozilla Firefox inside a Docker Container but you want to access the Firefox browser on your local machine. You can do this using some simple steps that we are going to discuss in this article.

There can be two types of applications (usually services) that you can containerise,

  • Applications that run as a Background Service (like a Database, WebServer, etc)
  • GUI Applications that (obviously!) run in the foreground

The second option is what we will see now,

Now let’s start our main task, here we are going to launch 2 GUI application one is firefox and other is Nautils File Manager.

So first we are going to create a new docker images for both firefox and nautils file manager using the Dockerfile.

Here I am build my images on the AWS instance in that , I am already configure the docker software. So we have to just create a Dockerfiles .

In that, We have to create a separate folders for both the Dockerfiles. In my case, I am creating the “dockgui” and “dockgui2” folders for firefox and file manager respectively.

In dockgui , We create a Dockerfile for firefox image. And for creating this new image we are using the CentOS image as a base OS.

In dockgui2 , we create a Dockerfile for a file manager image. And while creating this dockerfile we use ubuntu as a base OS.

Now , We created our 2 Dockerfiles in different folders . In my case there is no any container running. So let’s do our main part and that is build the image using our created Dockerfile. First We build a image a image for firefox for that use command..

“ docker build (Dockerfile Folder name) -t (image name) ”

Now , here our firefox image is successfully created. So let’s build the file manager image.

So here our file manager image also successfully build.Now let’s see our created images..

We can see that our 2 images are created well. Now we have to push that images on the Docker Hub. For that first you have to login to Docker Hub account from your CLI. And after that push the image using command..

“docker push (image name)”

Now let’s see our images are successfully pushed in Docker Hub or not..

You can see that our images are there. Now next part is we are pull that images in any other OS. Here I am pull this images on the RHEL8 OS for seeing the output.

Here we pull our images successfully. Let’s see it is pulled or not ..

Now Using that images we are launch the container for firefox and file manager. For that run the command..

“ docker run -it — rm -e DISPLAY=$DISPLAY -v /tmp/.X11-unix:/tmp/.X11-unix — net host (image name) ”

Now our centos firefox launched on the top of docker container.Let’s see the output.

Here our firefox is successfully launched. Now it’s turn to launch the file manager.

Here our file manager also successfully launched.Let’s check the output.

In that file manager , I am created one folder having name “mytask26”.It is working great.

See It show there properties also.

So here we can say ,our task is successfully completed with great working .

I hope this article help you a lot and you like it..If yes then clap and share to our friends..

If you want to connect with me then below is my LinkedIn Profile..

Thanks for reading..Have a Great Day..!!



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