GUI container on the Docker

Manojnagabairu
3 min readSep 7, 2022

*Task Description* đź“„

đź“Ś *GUI container* on the *Docker*

đź”… Launch a container on docker in GUI mode .

đź”… Run any GUI software (Firefox) on the container.

Let’s Start

  1. First I created my own Dockerfile which have already Firefox installed using Image called centos latest version . Here below is my Dockerfile.
FROM centos:latest
RUN yum install firefox -y
CMD ["/usr/bin/firefox"]

2. Now build this images using docker build command.

  • docker build -t . <name>:<tag>

3. Now image successfully created. Just for cross verify can use below command.

  • docker images | grep firefox

Running Firefox container in GUI mode

  • We know that if we start firefox container directly then it may show errors like below.
  • It clearly shows that if we want to run docker container of firefox then we need to pass “DISPLAY” as a environment variable. For passing the environment variable just check the help from below command.
docker container run --help
  • If you pass environment variable but again it might give errors like below
  • To resolve this above issue we need to pass one more option called — net=host because — net=host option is used to make the programs inside the Docker container look like they are running on the host itself, from the perspective of the network. It allows the container greater network access than it can normally get.
docker run -it --net=host --env="DISPLAY" firefox:<tag>

So finally if you run above command………Application ( Firefox ) will launch inside docker container.

Now Firefox is Launch successfully in GUI mode which is running inside centos container.

🤗Thank You for reading this Article🤗

--

--