Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

docker-machine behind corporate proxy

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?

like image 251
eighilaza Avatar asked Jul 02 '15 15:07

eighilaza


People also ask

Does Docker use system proxy?

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.

What is a proxy server Docker?

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.

What is a container process proxy?

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.


2 Answers

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  
like image 130
Senri Avatar answered Sep 20 '22 04:09

Senri


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

like image 21
BMW Avatar answered Sep 21 '22 04:09

BMW