MLOPS— Task 02 👨🏻💻
Task Description 📄
📌 GUI container on the Docker
🔅 Launch a container on docker in GUI mode
🔅 Run any GUI software on the container
Why Run GUI Apps in Docker?
Running a GUI program in Docker can be a useful technique when you’re evaluating a new piece of software. You can install the software in a clean container, instead of having to pollute your host with new packages.
This approach also helps you avoid any incompatibilities with other packages in your environment. If you need to temporarily run two versions of a program, you can use Docker to avoid having to remove and reinstall the software on your host.
Let’s first try to run a GUI application (say, Firefox) inside a docker container.
For this first we will have to launch a container so here I am launching a container with centos image.
#docker run -it --name <osname> <image name>
As docker container doesn’t by default comes with firefox so we are installing it with yum cmd.
#yum install firefox -y
After installing Firefox, if you try to launch firefox using command
it will show the below error:
The error says that a “DISPLAY” environment was not found. So, here are the steps we are going to perform in order to solve the error:
- Create a Docker image that has firefox installed
- Launching container by providing it with a DISPLAY variable. Also, we will launch it in a ‘host’ network. Host network by default exposes a container so that it can be directly used from the base OS.
Dockerfile for creating the docker image:
Creating the docker image:
#docker build -t <imagename>:<version> <file location>#docker build -t dockerwidgui:v1 .here dot (.) represents that Dockerfile is in current folder
And now, it is the time to launch the container:
#docker run -it — name <osname> — env “DISPLAY” — net host <imagename>:<version>
And the GUI application (firefox) has been launched inside the Docker container:
We have successfully completed the task.
Github_url for code: https://github.com/nirali1219/MLOPS_task2
Open for queries and suggestions.