Spread the love

 55,330 views

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

Clap


Spread the love
Categories: Docker

Ajeet Raina

My name is Ajeet Singh Raina and I am an author of this blogging site. I am a Docker Captain, ARM Innovator & Docker Bangalore Community Leader. I bagged 2 special awards last year(2019): Firstly, “The Tip of Captain’s Hat Award” at Dockercon 2019, San Francisco, and secondly, “2019 Docker Community Award“. I run Collabnix Community Slack with over 5300+ audience . I have built popular GITHUB repositories like DockerLabs, KubeLabs, Kubetools, RedisPlanet Terraform etc. with the support of Collabnix Community. Currently working as Developer Relations Manager at Redis Labs where I help customers and community members adopt Redis. With over 12,000+ followers over LinkedIn & close to 5100+ twitter followers, I like sharing Docker and Kubernetes related content . You can follow me on Twitter(@ajeetsraina) & GitHub(@ajeetraina)

1 Comment

Largo · 16th September 2021 at 6:02 pm

Hi,

Hi Ajeet,

Currently I use a virtual machine that is connected to my guest wifi to open websites that I don’t yet fully trust. It’s a bit over the top. I need a lighter solution.

would running a browser in a docker isolate my browser from the rest of my PC to prevent any web-based attack, hack and whatnots?

Leave a Reply

Your email address will not be published. Required fields are marked *

Hey, Wait !

Stay Informed about what's happening around DevOps community and tools.