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

Why do we love .NET to the Core?

Why C# Corner is a HUGE deal for Stratis

RAM — explanation with weird 10-armed stock person analogy

Why Microservices Architecture?

【 Gate 21 | The Key of Authority 】

10 Best Types of Software Testing in Chennai

The Advantages of Golang

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

C’est la Vite

Code faster with lombok

Install MKVToolNix 65.0.0 on Ubuntu /AlmaLinux & Fedora

run mkvtoolnix from docker

SMB/CIFS, Docker-Compose and linux container on Windows