Running GUI application in Docker Container


For solving this issue I can show two methods, the first is manual and the second is Automation.

First Method(Manual)

docker pull centos
docker run --net=host -it --name c1 centos
docker run -it --net=host --env="DISPLAY" centos

Automation Method

docker run --net=host --env="DISPLAY" --name CONTAINER_NAME centosgui

There is one more way to make it possible.

We know that X11 server is responsible for GUI environment. So by enabling it we can run GUI application inside Docker.

The command to set X server socket is -v /tmp/.X11-unix/:/tmp/.X11-unix

echo $DISPLAY sets the display of container.

The display is set so now we can install firefox and run it.

If you find it riveting please upvote it.

Connect with me on LinkedIn | GitHub

Lifelong learning technologies