Browser GUI in Docker for Mac

What if you want to surf the net without worrying any harmful website that might cause problem to your computer? Use the browser in an isolated container is a clean solution here! This is a clean and easy guide to run browser with GUI in container for Mac in 5 mins.

Prerequisites

  • Docker for Mac
  • OS X (El Capitan)
  • XQuartz
  • Jessie Frazelle‚Äôs Firefox Dockerfile

Installation

Docker for Mac

Why Docker? In short, Docker has a more simplified structure compared to traditional VMs and better resources efficiency.

Go to Docker website and download Docker for Mac stable here, install and run.

XQuartz

Why XQuartz? We will need window system for GUI. XQuartz is the continuation to Apple's depreciated X11.app supported by the open source community.

Download XQuartz 2.7.10_rc5 here and install. After installation, log out and back in OSX.
Note: The default stable release XQuartz-2.7.9 has a bug in our case here.

Start

First run XQuartz. You can execute XQuartz app directly or type in the command below.

open -a XQuartz  

In XQuartz preference, go to "Security" and check "Allow connections from network clients"

XQuartz Preference

Then go to terminal and run following commands.

ip=$(ifconfig en0 | grep inet | awk '$1=="inet" {print $2}')  
xhost + $ip  

Here you can run Firefox in a Docker container with Download folder mounted!

docker run -d --name firefox -e DISPLAY=$ip:0 -v /tmp/.X11-unix:/tmp/.X11-unix -v $HOME/Downloads:/root/Downloads jess/firefox  

Comments

comments powered by Disqus