Running GUI Application on Docker Container

How to run applications that require a graphic user interface on the docker container.

Have you ever tried to run a GUI application on the docker container?

As we know docker container comes with a command-line interface in which we can not run GUI applications by default. So we have to provide it with a display and the host’s network driver.

Launching GUI Container

  • To launch a docker container we use the docker run command
docker run -i -t --name <container_name> <image_name>

→ -i enable the container to interact

→ -t provide the terminal.

  • To launch a container with GUI, we have to provide DISPLAY environmental variable to the container.

→ The container will basically use the Display adaptor of the Base OS to take the parameters of the mouse pointer, cursor, etc.

  • To set network adopter as host pass the following option to the docker run command.

I am going to use centos image with the latest version.

So over final command is:

docker run -it --name gui_docker --env="DISPLAY" --net=host centos:latest

Our container has been successfully launched, Now we can run GUI application in it.

Launching GUI application on Docker

To install jupyter notebook we have to install python in our container.

After successful installation of python, we will install jupyter notebook by pip package manager of python.

Now, this command will fail because jupyter notebook requires any browser to run.

So, we will install firefox to run the notebook.

Now, let's run jupyter notebook.

To bypass root power, it is asking to run with the following option


Now, our GUI application has been successfully launched.

Thanks, for reading…

Keep Learning Keep Sharing !!!