GUI Application Inside Docker Container🐋

What is Docker?

Docker is a tool designed to make it easier to create, deploy, and run applications by using containers. Containers allow a developer to package up an application with all of the parts it needs, such as libraries and other dependencies, and deploy it as one package. By doing so, thanks to the container, the developer can rest assured that the application will run on any other Linux machine regardless of any customized settings that machine might have that could differ from the machine used for writing and testing the code.
In a way, Docker is a bit like a virtual machine. But unlike a virtual machine, rather than creating a whole virtual operating system, Docker allows applications to use the same Linux kernel as the system that they’re running on and only requires applications be shipped with things not already running on the host computer. This gives a significant performance boost and reduces the size of the application.

Task Description 📄

📌 GUI container on the Docker

🔅 Launch a container on docker in GUI mode.

🔅 Run any GUI software on the container.

Step-1 : Install docker in your system

A) Configure yum for Docker repo :

Create a file “/etc/yum.repos.d/docker.repo”
[docker]
name=docker repo baseurl=https://download.docker.com/linux/centos/7/x86_64/stable/
gpgcheck=0

After this verify by “yum repolist” . You see some more software.

Step-2 : Pull centos image

docker pull centos:latest

Step-3 : Launch a Container

docker run -it — name <os_name> — net=host — env=”DISPLAY” — volume=”$HOME/.Xauthority:/root/.Xauthority:rw” <image>:<version>

We have to provide this as a option to share docker host i.e in our case RHEL8 XServer.

# share the Host’s XServer with the container by creating a volume
--volume="$HOME/.Xauthority:/root/.Xauthority:rw"
# to share the host display environment to the container.
--env="DISPLAY"
# to run container with host network
--net=host

Now, run the container by providing these option.

verify by checking the container is launched and the process is started or not ?

# To check whether the process is started or not(i.e. container is launched or not) 
docker ps

Step-3: Install required packages inside the container

# python package
# firefox package
yum install python36 firefox -y

let’s verify whether the packages are successfully installed or not?

# To verify the firefox package
rpm -q firefox
# To verify the python package
rpm -q python36

Step-4: Install required libraries

# installing required libraries for task
pip3 install jupyter

Let’s launch jupyter notebook :

# To launch the jupyter notebook
jupyter notebook --allow-root

Yeahh !! Our task is successfully completed 😃

🔰Keep Learning ❗❗🔰Keep Sharing ❗❗

--

--

Get the Medium app

A button that says 'Download on the App Store', and if clicked it will lead you to the iOS App store
A button that says 'Get it on, Google Play', and if clicked it will lead you to the Google Play store