Running a GUI application inside Docker Container
In this blog we are going to launch a container on Docker in GUI mode and run Firefox on that.
- Docker should be installed on a Linux OS
- Start docker container
To start docker container use command
systemctl start docker
After staring Docker you can follow these steps
Step 1 : Pull the docker image. You can use any container image. Here, I am using centos: latest
docker pull centos:latest
Step 2 : Now in your local host create a folder using
mkdir <folderName> and create a file in it using
Step 3 : Now in the file write below command to run Firefox.
RUN yum install firefox -y
Step 4 : Now we will use build command to build an Image from Dockerfile.
docker build -t firefox .
We have successfully built an Image. To check this, type
docker images this will show you Firefox image.
Step 5 : In this step we are going to run this firefox image.
docker container run -it --env="DISPLAY" --net=host firefox
Let’s understand this command
- run :- this keyword will launch the container
- -it :- this gives interactive terminal
- --net=host :- use to launch the container with host network.
- --env=“DISPLAY” :- This is use to share the display of the host to the container.
This is it, we have launched GUI application inside Docker Container. In this way you can run any GUI application.
Thank You Reading !!✌