Running GUI Application on Docker Container
Vivek Sharma
RedHat Certified in Containers and Kubernetes(EX180) ||Arth || Aspiring DevOps Engineer || Python || Docker || Ansible || Jenkins || Kubernetes || OpenShift || Terraform || GitHub || AWS || AZURE
ARTH - Task 26 ???????
Task Description ??
?? Launch a container on docker in GUI mode
?? Run any GUI software on the container
DOCKER
Docker is a popular open-source project written in go and developed by Dotcloud (A PaaS Company). It is basically a container engine that uses the Linux Kernel features like namespaces and control groups to create containers on top of an operating system.
Docker gives an isolated environment using the resources of the host system itself. It is very quick like in one second you get an entire new operating system.
ADVANTAGES OF DOCKER
- Return on Investment and Cost Savings.
- Standardization and Productivity.
- CI Efficiency.
- Compatibility and Maintainability.
- Simplicity and Faster Configurations.
- Rapid Deployment.
- Continuous Deployment and Testing.
- Multi-Cloud Platforms.
WHAT IS NEED TO RUN A GUI APPLICATION ON DOCKER CONTAINER
we can use container's isolated environment to test a GUI application, so it won't risk our main operating system where it might create any conflict with the running applications. There can be many more requirements.
REQUIREMENTS TO RUN A GUI APPLICATION
To run a GUI application system should have XSERVER but docker container don't have one, so we have share the host's XSERVER and the display environment. we have to launch the container with host network drive.
If you try to run run GUI Application without fulfilling these requirement you will get error like this -
For launching Firefox on a docker container I have created an image using this Dockerfile
We can use command ( # docker build <image name> .) to build the docker image
To confirm image is build you use ( # docker images ) to view all the images
Now we have to launch a container satisfying all the above requirements using command -
# docker run -it --net host -v "$HOME/.Xauthority:/root/.Xauthority:rw" -e "DISPLAY" <image name> bash
This command will give bash shell of the container launched. Now to launch the Firefox use command -
# /usr/bin/firefox
This will open a new window with Firefox running.
Similarly we can run any GUI Application on Docker container by installing respective package instead of Firefox and then running similar set of commands.
THANK YOU FOR READING...................