Running GUI Applications in Docker Container

Now, let’s see how to launch GUI application in docker:

Step — 1: Start the Docker Service

To start the docker service and check its status, use the commands:

#systemctl start docker#systemctl status docker

Step — 2: Pull the Centos Image from DockerHub

We should make a Docker Container using the centos Image that is already available in DockerHub Repository. Use the command:

#docker pull centos

Step — 3: Creating Dockerfile

Step — 4: Build the Docker image using Dockerfile

we have 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.
  • <container_image> — In this case, the container image is “GUI”.
  • Dot operator: Indicates that the Dockerfile is present in the current folder.

Step — 5: Launch the GUI Container:

We will use the docker run command to launch the container.

#docker run --env="DISPLAY" --net=host --name=firefox gui

Customized Docker Image Building :

Let’s say we want to run the “firefox” program inside Docker Container. So, what we can do is — We can create one Docker Image & can say whenever any container launches from this Image, run the Firefox program. So, let’s create the “Dockerfile”…

FROM centos:8
RUN yum install firefox -y
CMD firefox

Thank you

--

--

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