Running GUI application on Docker

Harshal Kondhalkar
3 min readJun 1, 2021

--

Have you ever thought of running GUI application on docker?

In most of the cases we don’t need to launch a GUI app on docker but what if there is a use-case where we want to deploy a GUI app on docker. In that case the answer is “yes”. We can a deploy a GUI app on top docker container with help of environment variable and networking.

Step 1: Create workspace for Dockerfile

mkdir test

Step 2: Create Dockerfile

vim Dockerfile

Step 3: Creating Dockerfile

  • Write the following commands

Step 4: Build the DockerFile using Docker build

docker build -t firefox:v1 .

Step 5: Running docker container with few options-

Firefox need one environmental variable to run itself. The shell actually help Firefox to display it’s GUI tab on screen. But we definitely know that Docker Container does not have a screen to run the Firefox as its a GUI application, that’s why we need to tell the container to use the host system’s GUI screen and for that we going to use the environmental variable using the option “env” in “docker run” command. Use the following options in the docker run command-

— env :value to set environment variables

— net=host: option to make the programs connect to the host system

docker run -it — env=”DISPLAY’ — net=host firefox:v1

  • Here, the “net” option used is related to networking concept, but basically its a option to connect your docker container with your RHEL8 docker host’s main network card. This option is actually needed because after launching container it will provide us the Firefox software in GUI window, now whatever we are searching in this window needs to go to the Docker Container via Docker Host. For that connectivity we add our Docker Host network to the container.

Step 6: Firefox launched from container

Thank-you!

--

--

No responses yet