GUI Application inside Docker

MLOPS— Task 02 👨🏻‍💻

Task Description 📄

📌 GUI container on the Docker

🔅 Launch a container on docker in GUI mode

🔅 Run any GUI software on the container

Why Run GUI Apps in Docker?

This approach also helps you avoid any incompatibilities with other packages in your environment. If you need to temporarily run two versions of a program, you can use Docker to avoid having to remove and reinstall the software on your host.

Let’s first try to run a GUI application (say, Firefox) inside a docker container.

#docker run -it --name <osname> <image name>

As docker container doesn’t by default comes with firefox so we are installing it with yum cmd.

#yum install firefox -y

After installing Firefox, if you try to launch firefox using command


it will show the below error:

The error says that a “DISPLAY” environment was not found. So, here are the steps we are going to perform in order to solve the error:

  • Create a Docker image that has firefox installed
  • Launching container by providing it with a DISPLAY variable. Also, we will launch it in a ‘host’ network. Host network by default exposes a container so that it can be directly used from the base OS.

Dockerfile for creating the docker image:

Creating the docker image:

#docker build -t <imagename>:<version> <file location>#docker build -t dockerwidgui:v1 .here dot (.) represents that Dockerfile is in current folder

And now, it is the time to launch the container:

#docker run -it — name <osname> — env “DISPLAY” — net host <imagename>:<version>

And the GUI application (firefox) has been launched inside the Docker container:

We have successfully completed the task.

Github_url for code:

Open for queries and suggestions.



-Thank you :)

ARTH Learner | AWS | Devops | Docker | Ansible | Kubernetes | MLOPS | Linux | Python | Python flask | AI | ML | DL | CV | MongoDB | Hadoop | GIT | GitHub