Monday, May 23, 2016

Detailed guides to set up docker on windows behind a firewall

Recently just set up a docker to work under windows behind a corporate firewall

Prerequisite:
 - Enable VT-X in BIOS
 - Setup Server environment variable in the host PC
   HTTP_PROXY=http://<proxy>:<port>
   HTTPS_PROXY=http://<proxy>:<port>
   NO_PROXY=192.168.99.100

1. Download docker toolbox for windows and install it

2. Start Docker quick terminal
I removed the default image and recreate one.
docker-machine stop default
docker-machine rm default

3. Create a image named dev
docker-machine create --driver virtualbox dev

4. Set up the start environment variable
docker-machine env dev
eval $("C:\program files\docker toolbox\docker-machine.exe" env dev)
docker ps

5.Remote SSH to the image and set up proxy in it
docker-machine ssh dev
sudo -s
echo "export HTTP_PROXY=http://<proxy>:<port>" >> /var/lib/boot2docker/profile
echo "export HTTPS_PROXY=http://<proxy>:<port>" >> /var/lib/boot2docker/profile

cat /var/lib/boot2docker/profile
exit

6. Restart the image
docker-machine restart dev

7. Run hello-world to test
docker run hello-world

-----
There are also a few useful command to use
docker ps -a
docker run -p 3000:3000 -v $(pwd):/var/www -w /var/www node npm start

-----------
Updated, just found a blog talking about this as well.
http://www.netinstructions.com/how-to-install-docker-on-windows-behind-a-proxy/