GUI container on the Docker. Launch a container on docker in GUI mode. Run any GUI software on the container.
Step — 1: Start the Docker Service
We need to make sure the Docker Service is up and running.
systemctl is-active docker
This command checks whether the Docker Service is active or inactive.
systemctl start docker
This command starts the Docker Service.
systemctl status docker
This provides a detailed overview of the docker service
# Allow X server con
# Installing the sources for the locales
RUN yum install -y glibc-locale-source
# Setting up the default locale to en_US.UTF-8
RUN localedef --no-archive -i en_US -f UTF-8 en_US.UTF-8 && \
export LANG=en_US.UTF-8
# Installing Necessary packages including firefox
RUN yum install -y dbus-x11 PackageKit-gtk3-module libcanberra-gtk2 firefox
# Generating a universally unique ID for the Container
RUN dbus-uuidgen > /etc/machine-id
# Starting Firefox application
CMD /usr/bin/firefox
glibc-locale-source is the source file of many locales.
dbus-X11 is X11 -requiring add-ons for D-Bus.
PackageKit-gtk3-module is used to install fonts automatically using PackageKit
Libcanberra is an implementation of the XDG Sound Theme and Name Specifications, for generating event sounds on free desktops, such as GNOME. It comes with several backends (ALSA, PulseAudio, OSS, GStreamer, null) and is designed to be portable.
Step — 5: Building the Docker image from Dockerfile
Now we have to build the Docker image using the docker build command.
docker build -t <container_image> .
-t — Tag option helps us to tag the image with a proper name.
# We are going to use the Latest version of Centos
FROM centos:latest
# Installing the sources for the locales
RUN yum install -y glibc-locale
# Setting up the default locale to en_US.UTF-8
RUN localedef --no-archive -i en_US -f UTF-8 en_US.UTF-8 && \
export LANG=en_US.UTF-8
# Installing Necessary packages including firefox
RUN yum install -y dbus-x11 PackageKit-gtk3-module libcanberra-gtk2 firefox
# Generating a universally unique ID for the Container
RUN dbus-uuidgen > /etc/machine-id
# Starting Firefox application
CMD /usr/bin/firefox
glibc-locale-source is the source file of many locales.
dbus-X11 is X11 -requiring add-ons for D-Bus.
PackageKit-gtk3-module is used to install fonts automatically using PackageKit
Libcanberra is an implementation of the XDG Sound Theme and Name Specifications, for generating event sounds on free desktops, such as GNOME. It comes with several backends (ALSA, PulseAudio, OSS, GStreamer, null) and is designed to be portable.
Step — 5: Building the Docker image from Dockerfile
Now we have to build the Docker image using the docker build command.
docker build -t <container_image> .
-t — Tag option helps us to tag the image with a proper name.
Dot operator at the last means that the Dockerfile is present in the current folder.
Step — 6: Launch GUI Container from the Image
We will use the docker run command to launch the container.
We must 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.
-e DISPLAY=$DISPLAY
Providing a Docker container with access to your host’s X socket is a straightforward procedure. The X socket can be found in /tmp/.X11-unix on your host. The contents of this directory should be mounted into a Docker volume assigned to the container.
-v /tmp/.X11-unix/:/tmp/.X11-unix/
These extra arguments are used to set up the base OS environment inside the container.
docker run -e DISPLAY=$DISPLAY \
-v /tmp/.X11-unix/:/tmp/.X11-unix/ \
--name firefox gui-container
Our GUI Software Firefox is up and running.
Comments
Post a Comment