Running GUI Application on the top of Docker Container
Docker is a software platform that allows you to build, test, and deploy applications quickly. Docker packages software into standardized units called containers that have everything the software needs to run including libraries, system tools, code, and runtime.
Docker Containerise two types of application-
- Applications that run as a Background Service like a Database, WebServer, etc.
- GUI Applications that run in the foreground.
This article will show you how to Containerise GUI Application inside a Docker Container. Here we will be Launching Jupyter Notebook inside a Docker Container. For a GUI Application to run, we need to have a XServer which we are going to have by
- Sharing Host Display Environment Variable.
$ --env=“DISPLAY”
2. Running the Host network drive.
$ --net=host
Lets get started with steps involved in launching a GUI Application inside a Docker Container.
Step 1:
Assure DISPLAY environment variable to be :0(most of the time its :0).
$ echo $DISPLAY
But exception can be there due to your display than for that export the DISPLAY environment variable to :0 value
$ export DISPLAY=:0
Step 2: Command add the user( Client ) to the list of allowed connection for the X-server.
$ xhost +
Step 3:
Run the Docker container using the command.
$ sudo docker run -it — env=”DISPLAY” — net=host — name ML_OPsTask2 centos:latest
Step 4:
After that install firefox using the cmd.
# yum install firefox
Step 5:
After the installation of firefox now install python3 and jupyter notebook using the cmd.
# yum install python3 -y && pip3 install jupyter
Step 6:
Run firefox and see the result of launching the firefox application on the Docker container.
Step 7:
Now run the Jupyter Notebook using cmd
# jupyter notebook — allow-root
I hope that you had enjoyed the article and learned a new concept today :D
For any query contact me through my Linkedin profile mentioned below.