In this Article, we are going to see the method of enabling the graphical user interfaces within Docker containers for a particular application eg firefox.
Task Description 📄
📌 GUI container on the Docker
🔅 Launch a container on docker in GUI mode
🔅 Run any GUI software on the container
✨Step 1:- Use any system as a Base OS, here I am using AWS instance as my base system.
Now login to this instance and create one separate folder to write code — ->eg “mkdir dock1” and also create a “Dockerfile” into that folder to build a custom Docker image.
Here I have created a Dockerfile for Firefox application so it will create a Docker Image that has GUI support for Firefox
✨Step3:- Now we have to build a Docker image for this use below command — →
command:-docker build <Dockerfile_folder name> -t <image_name>
Here our Firefox image is created successfully.
✨Step4:- Now let’s check the image in the Docker Image list
✨Step5:- Now push this firefox image to Docker Hub . for this first log in to your Docker Hub account and use the following command to push the image
command:-docker push <user_name/image_name>
here we can see our image is successfully pushed to the docker hub. let’s check also on the docker hub portal — — ->
✨Step6:- Now we have to pull this image so, here I am using RHEL8 OS as a Base Os
Now let's check our image is pulled successfully or not
✨Step7:- Now launch the Docker container using this image.
Command:-docker run -it — rm -e DISPLAY=$DISPLAY -v /tmp/.X11-unix:/tmp/.X11-unix — net host <image name>
After running this command our CentOS firefox will launch let’s see the output — →
Here we can see our firefox is launched successfully with GUI support.
Here we successfully build a GUI Container on Docker.
THANKS FOR READING….