Ajeet Raina Docker Captain, ARM Innovator & Docker Bangalore Community Leader.

Running a Web Browser in a Docker container

1 min read

Are you still looking out for a solution that allows you to open multiple web browsers in Docker containers at the same time? Most people use Docker as a standard unit of software that packages up code and all its dependencies so that the application runs quickly and reliably from one computing environment to another. A Docker container image is a lightweight, standalone, executable package of software that includes everything needed to run an application: code, runtime, system tools, system libraries, and settings.

Today, all major cloud providers and leading open source serverless frameworks use Docker, and many are leveraging Docker for their container-native IaaS offerings. Docker makes development efficient and predictable. Docker takes away repetitive, mundane configuration tasks and is used throughout the development lifecycle for fast, easy, and portable application development – desktop and cloud. Docker’s comprehensive end-to-end platform includes UIs, CLIs, APIs, and security that are engineered to work together across the entire application delivery lifecycle.

Let us agree to the fact that browser testing can be a pain for the most seasoned testers, but it’s particularly challenging for newbies. In today’s world, an application behaves differently in different browsers, in different resolutions, and sometimes in different operating systems. To give new testers a running start, testing these web browsers in Docker containers can expedite their testing effort.

Under this blog, I will show you how to run Firefox web browser in Docker container. This has been tested on Docker Desktop for Mac.

Pre-requisite

  • Install Docker Desktop
  • Enable File Sharing under Docker Desktop > Preference as shown below:

The GUI of the application is accessed through a modern web browser (no installation or configuration needed on the client side) or via any VNC client.

Launch the Firefox docker container with the following command:

 % docker run -d \    
    --name=firefox \
    -p 5800:5800 \
    -v /Users/ajeetraina/datas:/config:rw \
    --shm-size 2g \
    jlesage/firefox
30220d1c22fa13ce24eb2ddaad7de88f67eefb8ce9388701aa5666795561b8eb

Open https://localhost:5800 and access the firefox over the browser.

You can check what’s happening in the backend by running the below CLI:

% docker logs -f 3022
The VNC desktop is:      30220d1c22fa:0
PORT=5900

******************************************************************************
Have you tried the x11vnc '-ncache' VNC client-side pixel caching feature yet?

The scheme stores pixel data offscreen on the VNC viewer side for faster
retrieval.  It should work with any VNC viewer.  Try it by running:

    x11vnc -ncache 10 ...

One can also add -ncache_cr for smooth 'copyrect' window motion.
More info: http://www.karlrunge.com/x11vnc/faq.html#faq-client-caching

Mozilla Firefox 84.0.2
01/05/2021 06:22:38 Got connection from client 127.0.0.1
01/05/2021 06:22:38   other clients:
01/05/2021 06:22:38 Got 'ws' WebSockets handshake
01/05/2021 06:22:38 Got protocol: binary

Click on “Dashboard” to see what percentage of resources this Docker container is consuming:

Click on the console sign just near to the stats to open browser.

You can also open terminal icon next to the browser option to enter into the firefox container shell:

ajeetraina@Ajeets-MacBook-Pro ~ % docker exec -it 30220d1c22fa13ce24eb2ddaad7de88f67eefb8ce9388701aa5666795561b8eb /bin/sh
/tmp # free -m
              total        used        free      shared  buff/cache   available
Mem:           1987        1365          82         218         538         359
Swap:          1023         475         548
/tmp # cat /etc/os-release
NAME="Alpine Linux"
ID=alpine
VERSION_ID=3.12.6
PRETTY_NAME="Alpine Linux v3.12"
HOME_URL="https://alpinelinux.org/"
BUG_REPORT_URL="https://bugs.alpinelinux.org/"
/tmp # 

Further References

Have Queries? Join https://launchpass.com/collabnix

Ajeet Raina Docker Captain, ARM Innovator & Docker Bangalore Community Leader.

16 Replies to “Running a Web Browser in a Docker container”

  1. Тhanks foг ones marvelous posting! I genuinely enjoyed reading it, you could be a great author.
    I will be sure to ƅookmаrk your blog and will come bɑck someday.

    I want to encourage that you continue your great job, have a
    nice morning!

  2. Heⅼlo! Quick questіon that’s entirely off topic. Do you know how to mаke your sitе mobile friendly?
    My sіte looks weird when browsing from my iphone. I’m tгying to find a template
    or pluɡin that might be able to fiⲭ this issue. If you have any recommеndɑtions,
    please share. Cheers!

  3. Тhanks foг ones marvelous posting! I genuinely enjoyed reading it, you could be a great author.
    I will be sure to ƅookmаrk your blog and will come bɑck someday.

    I want to encourage that you continue your great job, have a
    nice morning!

  4. I really ⅼike what you guys are usually up too. This ѕort of ϲlever
    work and exp᧐sսre! Kеep up the veгy good works guys
    I’ve included you guys to blogroll.

  5. I’m really imрressed along with your writing talents as smartly as with
    the layout in your blog. Ιs that this a paid tһeme
    or did yοu modify it your self? Eіther way stay
    up the nice high quality writing, it is uncommon tο look a great weblog liкe this one nowаdays..

  6. Oh my ɡoodness! Amazing article dude! Thank you
    s᧐ much, However I am experiencіng difficultiеs with your RSS.

    I don’t know why I can’t sᥙbscribе to it. Is there anybody having
    the ѕame RᏚS issues? Anyоne who knows the solᥙtion can you kindly respond?
    Thanks!!

  7. My bгother recommended I might like this web site.
    He waѕ entiгely right. This рost truly made my dɑy.
    You can not imagine just how much time I had spent for thiѕ infоrmɑtion! Thankѕ!

Leave a Reply

Your email address will not be published.

© Copyright Collabnix Inc

Built for Collabnix Community, by Community