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
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
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.
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
Step 4. Now let's Download any GUI software for eg. Firefox.
yum install firefox
Step 5: Our Firefox is installed successfully. Lets run it by simply running a following command :
firefox
Hence, Firefox is running successfully.
Good job Sheersh Jain
Nice work bro
Keep it up Sheersh Jain
Good
Nice!