Skip to content

Instantly share code, notes, and snippets.

@mflorence99
Last active August 29, 2015 14:23
Show Gist options
  • Save mflorence99/5f2665995d638dddecfc to your computer and use it in GitHub Desktop.
Save mflorence99/5f2665995d638dddecfc to your computer and use it in GitHub Desktop.
How to Run boot2docker from Behind Corporate Firewall

How to Run boot2docker from Behind Corporate Firewall

Motivation

It took me a long time to figure this out, so I wanted to memorialize the solution I found in case it helps anyone else.

The objective is to run boot2docker on OS X behind a corporate firewall.

Prerequisites

Read and follow the instructions on the official Mac OS X Installation page. You won't get past the docker run hello-world step because if you're reading this you're behind a corporate firewall that won't allow it without going through a proxy. But in my experience, it is well worth reading all the steps first.

Configuring the Proxy Settings

Now you've read the installation documentation you'll understand that boot2docker actually runs as a mini-VM within OS X. So no existing proxy configuration settings apply, and you have to duplicate them as described next.

  # assume boot2docker init already successful
  # assume boot2docker up already successful
  boot2docker ssh
  
  # now the command prompt will say something like: 
  # docker@boot2docker:~$
  
  # we need root access:
  sudo -s
  
  # now configure the proxy
  echo "export HTTP_PROXY=http://[uid]:[pw]@corporate.proxy.com:[port]" >> /var/lib/boot2docker/profile
  echo "export HTTPS_PROXY=http://[uid]:[pw]@corporate.proxy.com:[port]" >> /var/lib/boot2docker/profile
  
  # for verification
  cat /var/lib/boot2docker/profile
  
  # exit out of ssh session
  exit
  exit
  
  # restart boot2docker
  boot2docker restart
  boot2docker up
  
  # now you should be able to proceed with installation steps
  docker run hello-world
  

Considerations

Almost all of the boot2docker file system isn't persistent. That means it gets recreated each time you run boot2docker up. The configuration in /var/lib/boot2docker/profile is an exception and you only have to do this once.

Until you are forced to change your password, of course! It certainly sucks to have to hold your password in a plaintext file, but it sucks even more when you have to track down all the places you've done so every ~30 days when you have to change it.

I think this approach is simple and foolproof and I just have a script I keep up-to-date to sed my new password in all the places I have to change it.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment