docker-machine behind corporate proxy

With current docker machine version, I can't find better way to do the change as in boot2docker (Docker/Boot2Docker: Set HTTP/HTTPS proxies for docker on OS X)

If you manually set the proxy in /var/lib/boot2docker/profile in docker machine, after restart it, the proxy setting will be removed automatically.

So I have to create a docker machine with --engine-env set for proxy

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 \
    proxybox

NOTES:

This is a two-years-old answer, there are a lot of changes happened in docker, so if you still can't make it work behind the proxy, please read @Senri's answer and others.

Documentation: create docker machine


As previously mentioned, you can edit the file at

$HOME\.docker\machine\machines\default\config.json

and set the HTTP_PROXY, HTTPS_PROXY and NO_PROXY variables (or delete them):

 "HostOptions": {
        "Driver": "",
        ...
        "EngineOptions": {
           ...
            "Env": [
              "HTTP_PROXY=http://10.121.8.110:8080",
              "HTTPS_PROXY=http://10.121.8.110:8080",
              "NO_PROXY=192.168.23.4"
            ],

After the file has edited, you only have to execute:

docker-machine provision 

Existing docker-machine config can be modified to add environment for the proxy. The config.json at $HOME/.docker/machine/machines//.config.json can be edited.

Add "HTTP_PROXY=http://example.com:8080" to Env in config.json. Restart the machine, and you are all set.


If you have already the machine (VM) created, you can configure the proxy like this :

1- SSH into the docker dev host: docker-machine ssh dev
2- Add the following lines to /var/lib/boot2docker/profile (this file is read-only, use sudo)
    export HTTP_PROXY=http://<proxy>:<port>
    export HTTPS_PROXY=http://<proxy>:<port>
3- Exit the ssh session and restart the docker machine: docker-machine restart dev 

Source