Launching Google Chrome on Docker container


Launch GUI applications(Google Chrome in this case) on top of Docker container.

Content of this Blog

  • Prerequisite
  • Project Understanding
  • Output


For Docker, refer the following link:

Project Understanding

Docker containers are by default CLI-based in nature and requires a physical display to run GUI applications. The way to do so involves sharing of Docker host’s display with the container.

In order to perform the above operation, two important concepts needs to be understood which are as follows:

  1. X11 or X Server
  2. DISPLAY environment variable

Let’s understand each one of them

X11 or X Server

X11 is a client/server windowing system for bitmap displays. It is implemented on most UNIX-like operating systems and has been ported to many other systems.

X Server is the program or dedicated terminal that displays the windows and handles input devices such as keyboards, mouse and touchscreens.

DISPLAY environment variable

The DISPLAY environment variable is used by all X clients to determine what X server to display on. Since any X client can connect to any X server that allows it, all X clients need to know what needs to be displayed upon startup.

The format of the DISPLAY variable is



  • hostname: Name or IP of the host
  • D: Display number in case of multiple displays (usually 0)
  • S: Screen number in case of multiple screens (usually 0)

Implementation: Dockerfile

FROM centos:latest
LABEL maintainer "Satyam Singh"

RUN dnf update -y
COPY google-chrome.repo /etc/yum.repos.d/
RUN yum install google-chrome-stable -y
ENTRYPOINT ["google-chrome","--no-sandbox"]

The above Dockerfile updates the DNF/YUM repository and copies the repository required for installation of Google Chrome in yum.repos.d directory, then it installs it using yum and then sets an entrypoint for launching Google Chrome.

Docker Host : RHEL 8

Implementation: Command used for building an image

docker build -t <image_name>:<version_tag> <path_to_Dockerfile>

Implementation: Command used to run Google Chrome within the container

docker run -it -e DISPLAY=:0 -v /tmp/.X11-unix:/tmp/.X11-unix -- chrome <URL>


  • -e stands for export and is used for exporting the value of environment variable DISPLAY
  • -v stands for bind mount to a volume i.e., attaching a volume

The X server folder i.e., /tmp/.X11-unix present in the host is mounted to the Docker container using -v option. The reason behind the same is to provide an X server to the container for running GUI applications.


Command Used
Command Output




Love podcasts or audiobooks? Learn on the go with our new app.

Recommended from Medium

Syncfusion Essential Studio 2020 Volume 2 Is Here!

Syncfusion Essential Studio 2020 Volume 2 Is Here!

Advanced Positioning In CSS


Boardroom dual mining launches and liquidity mining weights adjustment

Traveling through the App: the Segue magic! — Part 1

60 days to become a game developer. Days 41 & 42.

10 Best Udemy Courses for Python Developers in 2022

best Udemy courses for Python developers

PHP 5.6 — 8.1 Benchmark with JIT included

Get the Medium app

A button that says 'Download on the App Store', and if clicked it will lead you to the iOS App store
A button that says 'Get it on, Google Play', and if clicked it will lead you to the Google Play store
Satyam Singh

Satyam Singh

More from Medium

Run your first “Ansible” playbook

How to serve multiple web applications on a single port and different subdomains using Nginx and…

How to create a Linux swap file

Introduction to Jib