Docker-machine proxy settings

Hi gitlab community. I’ll keep this short and sweet. I am stuck setting up a docker-machine based autoscaling runner solution on my vsphere lab. Simply put my lab has no direct internet access and gets service via a squid proxy.

I set up docker machine using the boot2docker iso, it all runs and deploys a VM but thats where the joy ends. Lo and behold there is no proxy settings so docker can’t pull images.

I have tried setting all sorts of environment variables within config.toml, I have tried adding all sorts of pre-execution scripts. I have found no solution whatsoever on the internet.

So simply put does anyone know a way to set the proxy variables on the gitlab docker-machine boot2docker vm?

See this link for how to configure docker with proxy: Control Docker with systemd | Docker Documentation

In short:

mkdir /etc/systemd/system/docker.service.d

create /etc/systemd/system/docker.service.d/http-proxy.conf with the following values:

[Service]
Environment="HTTP_PROXY=http://x.x.x.x:3128"
Environment="HTTPS_PROXY=https://x.x.x.x:3128"
Environment="NO_PROXY=localhost,127.0.0.1,gitlab-registry.example.com"

replace x.x.x.x with the IP address of your proxy server, or even it’s FQDN if it is configured in DNS. Change the port form 3128 if using a different port for your proxy. If you don’t want to proxy certain addresses, add to the third line by IP address or FQDN (for example like mine with gitlab-registry.example.com). Separate each item with a comma.

systemctl daemon-reload
systemctl restart docker

your docker daemon is now configured to use a proxy.

This is not docker, its docker-machine. It is an iso that gets booted on a VM and hosts docker containers.

Everything you shared is not applicable as you don’t manage the system at all directly so I can’t change anything in systemd etc. The VM is spun up automatically on demand and thats it.

From the lack of information on the web I get the feeling gitlab have failed to include.an essential piece of functionality in their docker-machine runner solution.

In standard docker-machine you can set env-machine variables when you launch them but thats not provided for in gitlab’s implementation.

Ah yes my bad. Yeah it seems Docker dropped and deprecated Docker Machine but Gitlab forked it but according to this link haven’t added any additional features or have no intention of doing so: Install and register GitLab Runner for autoscaling with Docker Machine | GitLab

I’m surprised that the environment variables don’t work in Gitlab’s implementation of Docker Machine though. If it’s just forked just to maintain and provide it, then it should work the same.

It’s more the “wrappers” around docker-machine ie the runner executing the creation of docker-machine VMs, they don’t appear to passthrough the environment variables to the VM.

SOLVED in Docker-machine docker error