Docker behind proxy

Environment:

  • Window 10 Home
  • Docker toolbox
  • Proxy set in internet options

Problem:

  1. Docker can not pull images.
  2. Container can not connect to internet.

Solution:

To fix problem 1

Step1: remove your default machine
docker-machine rm default
Step2: recreate your default machine with proxy
docker-machine create -d virtualbox --engine-env HTTP_PROXY=http://your_proxy_url:your_proxy_port default
if that not working, you may try this option instead.
docker-machine create -d virtualbox \
    --engine-env HTTP_PROXY=http://example.com:8080 \
    --engine-env HTTPS_PROXY=https://example.com:8080 \
    --engine-env NO_PROXY=example2.com \
    default

To fix problem 2

Create or edit the file ~/.docker/config.json in the home directory of the user which starts containers.
{
 "proxies":
 {
   "default":
   {
     "httpProxy": "http://your_proxy_url:your_proxy_port"
   }
 }
}
Then restart ... computer and rebuild any thing.