GUI container on the Docker

GUI container on the Docker

Task Description 📄

📌 GUI container on the Docker


🔅 Launch a container on docker in GUI mode

🔅 Run any GUI software on the container

Pre-requisite :

✔ Docker should be installed in a System.


Now Let's Start.

Follow the bellow steps:-

Step 1. Lets start the docker service using the following command.

systemctl start docker


Step 2. Now let's pull the latest image of centos from Docker Hub.

You can provide the version if required , otherwise it will pick the latest image

docker pull centos:latest


No alt text provided for this image


Step 3. Now, there are two approach to run GUI container on the Docker:

Method 1:

a. Let's export the DISPLAY variable first.

export DISPLAY=:0
echo $DISPLAY


No alt text provided for this image


b. Now let's run the docker image by providing the following options -:

docker run -it --name docker1 --env=DISPLAY --net=host centos:latest

Here we are naming our OS as docker1 and giving network connection of our host OS .

Now our new container will use the DISPLAY of our host OS.

No alt text provided for this image

Method 2:

We need to have X11 Server on guest OS which is already available in all Linux systems. But, when we launch a container, we don’t have X11 server configured here. So we can mount this directory inside our container at the same path.

Simply run the following command :

docker run -it -v /tmp/.X11-unix/:/tmp/.X11-unix/ --net=host -e DISPLAY=$DISPLAY centos:latest
No alt text provided for this image

Step 4. Now let's Download any GUI software for eg. Firefox.

yum install firefox
No alt text provided for this image
No alt text provided for this image

Step 5: Our Firefox is installed successfully. Lets run it by simply running a following command :

firefox
No alt text provided for this image

Hence, Firefox is running successfully.

To view or add a comment, sign in

More articles by Sheersh Jain

  • Connect EFS to multiple instances in AWS

    Step 1. Launch an EC2 instance on AWS cloud.

    12 Comments
  • K-means Clustering in Machine Learning

    K-means clustering is one of the simplest and popular unsupervised machine learning algorithms. The objective of…

  • USE-CASE OF JavaScript

    JavaScript is a dynamic programming language that's used for web development, in web applications, for game…

  • Confusion matrix in Cyber crime

    Task Description 📄 📌 Cyber crime cases where they talk about confusion matrix or its two types of error. WHAT IS…

Others also viewed

Explore content categories