
To run GUI applications, we need X11 server.
X11 (or simply X) is a windowing system for bitmap displays, common on Unix-like operating systems. X provides the basic framework for a GUI environment: drawing and moving windows on the display device and interacting with a mouse and keyboard.
We need to forward the X11 socket of our local Linux machine to the Docker Container for it to use directly. Along with this, there is a need to forward the environment variable called display. After that, we need to set the permissions for the server host.
Creating the dockerfile
FROM centos:8
RUN apt-get -y update
RUN apt-get -y install firefox
RUN apt-get -y install xauth
EXPOSE 8887
CMD firefox
The above dockerfile does ,
create centos base image,
runs an apt update on it,
installs Xauth and Firefox,
It then exposes port 1234and ,
runs Firefox,
Xauth simply allows Docker Containers to access the Display Servers.
Copying the Cookie to connect X Server Displays
xauth list
Build the Docker Image
docker build -t os .
Run the Docker Container
docker run -it --net=host -e DISPLAY -v /tmp/.X11-unix os bash
Add the cookie to the list
xauth add <cookie>
xauth list
Run the Firefox Instance from the bash
firefox
Task Description 📄
📌 GUI container on the Docker
🔅 Launch a container on docker in GUI mode
🔅 Run any GUI software on the container
#vimaldaga #righteducation #educationredefine #rightmentor #worldrecordholder #linuxworld #makingindiafutureready #righeducation #arthbylw #docker #container