Run a GUI Software inside Docker Container

Abhishek Milind Songirkar
3 min readJun 1, 2021

--

In this article we are going to run ‘ Firefox ’ which is GUI software inside Docker container.

What exactly is Docker containers?

A Docker container is an open source software development platform. Its main benefit is to package applications in containers, allowing them to be portable to any system running a Linux or Windows operating system (OS).

🚀 Advantages of Docker containers 🚀

  • Mobility
  • Rapid Deployment
  • Agility
  • Scalable
  • Test , Roll-Back
  • Isolated Environment

🚀 This is all about Docker Containers, let’s move towards our real task 🚀

⚡ Installation Of Docker

This is my previous blog where I have written steps to install docker container and running ML code on top of centOS which is installed in it.

https://songirkar98.medium.com/creating-and-deploying-machine-learning-model-using-python-in-docker-container-49e781a3c849

STEP — 1 : Start Docker

# systemctl start docker
# systemctl enable docker
# systemctl status docker

First of all we need to stop firewall with command :

# systemctl stop firewalld

Step — 2: Pull the Centos Image from DockerHub

now we will make docker container with CentOS image which is available in Dockerhub Repository.

# docker images

This command will show all the docker images available in local directory or in saved repositories

docker pull centos:latest

This command will pull CentOS image from DockerHub and store to our local machine

Step — 3: Create Docker file

# vim dockerfile

in docker file we need to write:

FROM centos:latest
RUN yum install firefox -y && \
yum install net-tools -y
CMD /usr/bin/firefox

Step — 4: Building the Docker image from Dockerfile

  • Share the DISPLAY environment variable to the Container OS
--env=”DISPLAY”
  • Run the OS with the Host’s Network driver
--net=host
  • Other arguments are used to set up the base OS environment inside the docker container
docker run -it --env="DISPLAY" --net=host --name=firefox_gui

😍 Our GUI Software Firefox is up and running.

Applications:

basically GUI makes things slow but not everyone is familiar with CLI so, there are many platforms like GCP which is using this type of functionalities in providing cloud shell.

🙂 Thank you !!!

--

--