Running application like firefox inside docker container.
command to launch a container with centos image-
docker run -it — name my_gui_container centos:latest
Installing firefox by the command-
yum install firefox
The errors we received-
- Error regarding environmental variable $DISPLAY
- Error regarding no display connected.
Here to mount the folder that contain driver for gui, we need to re run the container i.e. remove the container and launch it again. To do so, the commands are-
docker rm my_gui_container
docker run -it — name my_gui_container -v /tmp/.X11-unix:/tmp/.X11-unix centos:latest
After this, only one error came i.e. DISPLAY environment variable one-
To solve this issue, create an environment variable DISPLAY=:0 and export it by command-
export DISPLAY=:0
New Error came that states that the connection is refused. We need to generate new dbus uuid for our machine by the command-
dbus-uuidgen > /etc/machine-id #send id to machine-id file
to correct this error we need to disable the xhost by the command-
xhost + # so that any host can connect & DISPLAY should have the same value as host i.e. :0
The final Output will look like-
Note- did after explanation.