Launching a GUI Application in Docker Container

Krishna Pal
3 min readMay 31, 2021

Task Description ๐Ÿ“„

๐Ÿ“Œ GUI container on the Docker

๐Ÿ”… Launch a container on docker in GUI mode

๐Ÿ”… Run any GUI software on the container

Pre-requisite

โœ” Docker should be installed in a System.

To check whether Docker is installed in your system or not, run the following to command to check it out.

command-: docker info

Now to start docker service type systemctl start docker command. After typing this command check the status of running docker service using command systemctl status docker

So our docker service is running. Itโ€™s time to pull image from DockerHub to our base OS Red Hat Enterprise Linux 8

Command to pull image from DockerHub-: docker pull <image_name>:<version_name>

Here, I am using CentOS latest image. To see downloaded images in docker

Command-: docker images

Now itโ€™s time to launch container on docker in GUI Mode.

Command-: docker run -it --net=host --env="DISPLAY" --name GuiOS -p 1234:8888 centos:latest

๐Ÿ‘‰ - -net = for using hostโ€™s network.

๐Ÿ‘‰ -env = for using environment variable (DISPLAY).

๐Ÿ‘‰ -p = for binding 8888 port no with port no.1234 of Dockerhost.

Now install any GUI Application inside container. Here I am installing Jupyter and Firefox.

command to install jupyter-: pip3 install jupyter
command to install firefox-: yum install firefox

Note-: For installing jupyter, you firstly have python3 installed in container. For installing python3 -:

Command-: yum install python3-pip
Jupyter installation
Firefox installation

After installation of these applications itโ€™s time to launch a GUI application.

Here, I am launching jupyter application with root user access.

Note-: Firefox must be installed in order to run jupyter.

Command-: jupyter notebook --allow-root

Hurray!โ€ฆ We successfully run GUI Application inside docker container.๐Ÿ˜

Jupyter notebook running

Thanks for readingโ€ฆ ๐Ÿ˜ƒ

--

--

Krishna Pal

Engineering Student || Aspiring DevOps Engineer || Tech Enthusiast