Running a GUI application inside Docker Container

Hello Everyone,

In this blog we are going to launch a container on Docker in GUI mode and run Firefox on that.


  • Docker should be installed on a Linux OS
  • Start docker container

To start docker container use command systemctl start docker

After staring Docker you can follow these steps

Step 1 : Pull the docker image. You can use any container image. Here, I am using centos: latest

docker pull centos:latest

Step 2 : Now in your local host create a folder using mkdir <folderName> and create a file in it using vim <fileName>

Step 3 : Now in the file write below command to run Firefox.

FROM centos:latest
RUN yum install firefox -y
CMD ["/usr/bin/firefox"]

Step 4 : Now we will use build command to build an Image from Dockerfile.

docker build -t firefox .

We have successfully built an Image. To check this, type docker images this will show you Firefox image.

Step 5 : In this step we are going to run this firefox image.

docker container run -it --env="DISPLAY" --net=host firefox

Let’s understand this command

  • run :- this keyword will launch the container
  • -it :- this gives interactive terminal
  • --net=host :- use to launch the container with host network.
  • --env=“DISPLAY” :- This is use to share the display of the host to the container.

This is it, we have launched GUI application inside Docker Container. In this way you can run any GUI application.

Thank You Reading !!✌



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