GUI Application over Docker Container

Launching GUI software on Docker Container using Manual and Dockerfile process.

For a GUI application to run, we need to have an Xserver which is available as part of every Linux Desktop Environment, But within a container, we don’t have any Xserver so,

🔰 Share the Host’s ‘Xserver’ with the container by creating a volume


🔰 Share the host’s ‘DISPLAY’ environment variable to the container


🔰Run container with host network drive with


Github URL for all Dockerfile codes:

So, First let us look manual process

Steps to run jupyter notebook in container:

Step1: Deploy Container

docker run -it --name os1 \
> --net=host \
> --env="DISPLAY" \
> --volume="$HOME/.Xauthority:/root/.Xauthority:rw" centos:latest

Step2: jupyter notebook needs browser to execute so, we will install dependencies

yum install firefox python3 -y

Step3: Let’s install jupyter now

pip3 install jupyter

Step4: Checking the installation

jupyter --versionjupyter core     : 4.7.1
jupyter-notebook : 6.4.0
qtconsole : 5.1.0
ipython : 7.16.1
ipykernel : 5.5.5
jupyter client : 6.2.0
nbconvert : 6.0.7
ipywidgets : 7.6.3
nbformat : 5.1.3
traitlets : 4.3.3

Step5: Finally launch jupyter notebook

jupyter notebook --allow-root

Steps to run gedit on container:

Step1: Deploy Container

docker run -it --name os1 \
> --net=host \
> --env="DISPLAY" \
> --volume="$HOME/.Xauthority:/root/.Xauthority:rw" centos:latest

Step2: Installing software

yum install gedit vim -y

Step3: Run gedit


Now, let’s look the Dockerfile process

Build process

Dockerfile is a text document that contains all the commands a user could call on the command line to assemble an image. Using docker build users can create an automated build that executes several command-line instructions in succession.

Step1: Dockerfile code

FROM centos:latest
RUN yum install firefox python3 -y
RUN pip3 install jupyter
ENTRYPOINT ["/bin/bash"]

Step2: Build

docker build -t <name_of _image>:<tag> .Example:
docker build -t jupyter-notebook-image:v1

Step3: Deploy Container

docker run -it --name os1 \
> --net=host \
> --env="DISPLAY" \
> --volume="$HOME/.Xauthority:/root/.Xauthority:rw" \
> jupyter-notebook-image:v1

Step4: Run command

jupyter notebook --allow-root

I have created a docker image named as rahul079/jupyter-notebook-gedit, which you can just pull and run the code!

Step1: Pull the image from docker hub

docker pull rahul079/jupyter-notebook-gedit:v1

Step2: Deploy Container

docker run -it --name os2 \
> --net=host \
> --env="DISPLAY" \
> --volume="$HOME/.Xauthority:/root/.Xauthority:rw"
> rahul079/jupyter-notebook-gedit:v1

Step3: Just run the command and start coding!

jupyter notebook --allow-root

or for gedit,


Done! That simple.

Thank You for Reading!

connect me :