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.
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 -yCMD /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> .
-t— Tag 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