How to run GUI application in the Docker Container?
--
So, let’s get started…
Step 1:- First, we will create a Docker image so whenever any container launches from this image, run the Firefox program.
FROM centos:latest
RUN yum install firefox -y
CMD firefox
Step 2:- Next, we have to build the image. Use the following command for the same:-
docker build -t myfirefox:v1
Step 3:- Now, we will launch the container from the above created image. The command is as follows:-
docker run -it — name firefoxos1 myfirefox:v1
Here, you can see that the “Error: no Display environment variable specified”. So, you must also provide the container with a DISPLAY environment variable. This instructs X clients — your graphical programs — which X server to connect to. Set DISPLAY in the container to the value of $DISPLAY on your host. The following is the command for the same:-
docker run -it — name firefoxos2 — env =”DISPLAY” — net=host myfirefox:v1
Thanks for reading :)