Run GUI Application Inside Docker Container

In this article, we are going to learn how to run a firefox browser inside the docker container.

Before starting, make sure you have installed the latest docker in your base os.

Lets start

Step1: Pull the latest centos image from the docker hub

# this will pull latest centos image from the docker hubdocker pull centos# here am using centos to launch the container

Step2: Creating Dockerfile

Here, we are going to create dockerfile to launch a container.

FROM centos:latestRUN yum install firefox -y && \
yum install net-tools -y && \
yum install PackageKit-gtk3-module libcanberra-gtk2 -y
CMD /usr/bin/firefox

PackageKit-gtk3-module — Install fonts automatically using PackageKit

Step4: Building the Docker image using the Dockerfile

In this step, we are going to build the Docker image using the Docker build command

docker build -t <container_image> .
  • -tTag option helps us to tag the image with a proper name.
  • Dot (.) operator means that the Dockerfile is used to present in the current folder.

Step5: Launch GUI container from the image

In this step, we are going to launch the gui container using the docker run command

docker run --env="DISPLAY" --net=host --name=firefox <Image_name>
  • --env=”DISPLAY” : — Share the DISPLAY environment variable to the Container OS

The container will basically use the Display adaptor of the Base OS to take the parameters of the mouse pointer, cursor, selected text, etc.

  • — net=host :— Run the OS with the Host’s Network driver

So, we successfully run firefox browser in the docker

Thanks !

--

--

--

Python Enthusiast

Love podcasts or audiobooks? Learn on the go with our new app.

Recommended from Medium

Terraform: Deploying A Two-Tier Architecture Using Terraform Cloud CI/CD

How to get Started in the Cloud: Skills

Last week in FAUN: Learning Go, MetalLB Configuration in Minikube & Python Logging Best Practices

Tips and points I learned from my daunting job searching expedition

Learn How to Learn How to Program

Hirb — A Great Ruby Gem

What is OpenType Font, OTF? what does it do?

Tech Debt: The Bill Comes Due

Get the Medium app

A button that says 'Download on the App Store', and if clicked it will lead you to the iOS App store
A button that says 'Get it on, Google Play', and if clicked it will lead you to the Google Play store
Ajmal Muhammed

Ajmal Muhammed

Python Enthusiast

More from Medium

Creating image using Numpy and Arrays

Step by step guide: How to participate in DaoMaker $MUON SHO

Difference between Static and Dynamic libraries in C

Run Klipper/OctoPrint In Void Linux