Running Docker on Windows 7 behind a proxy

Suci Lin
Suci Lin
Aug 8, 2017 · 4 min read

Running docker on Windows and Mac now is much easier than few years ago. “Docker for Windows”, one of Docker CE app, will enable Hyper-V and has supported Windows 10 and Windows Server 2016.

However, for some reasons, your system may not meet the requirements to run ”Docker for Windows“. You will need use Docker Toolbox to install and run docker. And for some reasons, you are working in a restrictive network environment with proxy servers. How should we deal with this condition?

I am going to share how I run Docker on Windows 7 behind a proxy. Yes, two points in this article: ❶ Docker on Win 7 and ❷ behind a proxy.


PRE-REQUISITES

  • Older 64 bit Windows systems that do not meet the requirements of Docker for Windows. There are some different procedures between Windows 7 and 8, especially on enabling virtualization. I use windows 7 in this article.
  • Confirm virtualization is enabled on your machine. For Windows 8, you can just check Performance tab from Task Manager. For Windows 7, you can run the Microsoft® Hardware-Assisted Virtualization Detection Tool and follow the on-screen instructions.

This is very easy. However, if you didn’t enable hardware virtualization, you may need enable VT-x or AMD-v from BIOS settings.


Install Docker

Download and install Docker Toolbox on Windows

The installer will install the following software:

  • Docker Client for Windows
  • Docker Toolbox management tool and ISO
  • Oracle VM VirtualBox
  • Git MSYS-git UNIX tools

Setup Docker

Start docker toolbox terminal

Launch a Docker Toolbox terminal by clicking “Docker Quickstart Terminal” icon. A shell script will check VirtualBox setting and create a new VM for docker by git-bash. Then Docker-machine can leverages VirtualBox’s VBoxManage to initialise, start, stop and delete the VM by Boot2Docker.

Setup a Proxy in git-bash

However, you may still need to setup a proxy in git-bash to get Boot2Docker iso file to create a VM for Docker-machine. Otherwise, you may see the error message as the below.

To setup and save the environment variable, you need to edit a “.bash_profile” for git-bash. Usually, the file in located in your Git home folder. Add the following code in your .bash_profile file. For NO_PROXY, you may also add ip address of docker-machine.

export HTTP_PROXY=http://account:password@proxy_Domain:port
export HTTPS_PROXY=https://account:password@proxy_Domain:port
export NO_PROXY=localhost,127.0.0.1,$docker-machine_ip

Restart “Docker Quickstart Terminal”, then it should look like the following figure.

Now Docker is up and running!

Error when connect to docker machine

If the IP address of the default docker machine was not added into the NO_PROXY variable list, you may occur the follow error.

Check ip of docker-machine.

check docker-machine information

Add ip of docker-machine by editing “.bash_profile”.

Modified .bash_profile

Verify your installation

Type the following command to pull a image and run a container for “hello-world”

$ docker run hello-world

Another way to setup a proxy by connecting the default docker-machine

This above describes how to add a proxy settings in git-bash and initiate a docker terminal via git-bash. We can also setup the proxy in a docker-machine by the following commands.

#connect docker-machine
$ docker-machine ssh default
$ sudo -s

Write a proxy to the configuration profile by the followings commands:

$ echo "export HTTP_PROXY=http://account:password@proxy_Domain:port" >> /var/lib/boot2docker/profile$ echo 
"export HTTPS_PROXY=https://account:password@proxy_Domain:port" >> /var/lib/boot2docker/profile
# See the content of profile to confirm the configuration
$ cat /var/lib/boot2docker/profile
#Restart docker machine
$ docker-machine restart default

Conclusion

Install Docker on win 7 with a proxy by the following steps:

  1. Install docker by Docker Toolbox
  2. Setup a proxy by adding settings ❶ in .bash_profile of git-bash or ❷ in default VM of docker-machine
  3. Try “hello-world” to verify the installation and settings

本文分享了當❶有需要在舊有的windows (win 7 or 8)且❷需要透過proxy連到外網的環境下使用docker時,所採取的安裝與設定步驟。

主要步驟為:

  1. 透過 Docker Toolbox 安裝docker
  2. 提供兩種方式增加proxy設定,❶ 可在git-bash 的.bash_profile 或是❷ 可透過ssh 連到default docker-machine 做環境變數修改
  3. 測試 “hello-world” 來確認是否安裝與設定順利

Suci Lin

Written by

Suci Lin

Data Engineer, focus on stream processing and IoT. Passionate about data storytelling with data visualization and building an engineering culture.

Welcome to a place where words matter. On Medium, smart voices and original ideas take center stage - with no ads in sight. Watch
Follow all the topics you care about, and we’ll deliver the best stories for you to your homepage and inbox. Explore
Get unlimited access to the best stories on Medium — and support writers while you’re at it. Just $5/month. Upgrade