I am trying to use docker-machine to create an instance on a private cloud (Openstack) that is behind a corporate http proxy.
Is it possible to tell docker-machine to use the proxy or do I need to have a glance image that is already pre-configure with the http_proxy env variable?
In Docker 17.07 and higher, you can configure the Docker client to pass proxy information to containers automatically. In Docker 17.06 and earlier versions, you must set the appropriate environment variables within the container.
docker-proxify is a docker-within-docker container that eases development when operating behind a restrictive firewall that requires a proxy server for outbound internet connectivity, by making the use of the proxy server transparent to the applications running inside the container.
Introduction. ContainerProxy is an application that launches and manages containers for users, to perform specific tasks. Examples include: Run interactive Shiny apps. Execute long-running R jobs.
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
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
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
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With