title: Docker-Machine and Swarm behind proxy
body: <p>I'm traing to set up docker swarm over my virtual cluster. First, I try to install the swarm-master on the localhost with docker-machine.</p>
  
  <p>The problem is that the machine need to use a proxy to access the discovery token.</p>
  
  <p>First I ask a token with swarm create. To do that, I created this file :</p>
  
  <pre><code>$cat /etc/systemd/system/docker.service.d/http_proxy.conf 
  [Service]
  Environment="HTTP_PROXY=http://**.**.**.**:3128/"    "HTTPS_PROXY=http://**.**.**.**:3128/" "NO_PROXY=localhost,127.0.0.1,192.168.2.100,192.168.2.101,192.168.2.102,192.168.2.103,192.168.2.104,192.168.2.105,192.168.2.106,192.168.2.107,192.168.2.108,192.168.2.194,192.168.2.110"
  </code></pre>
  
  <p>I restarted the daemon and I can pull the swarm image :</p>
  
  <pre><code>$docker run -e "http_proxy=http://**.**.**.**:3128/" -e "https_proxy=http://**.**.**.**:3128/" swarm create
  b54d8665e72939d2c611d8f9e99521b4
  </code></pre>
  
  <p>After I want to create the swarm master :</p>
  
  <pre><code>$docker-machine create -d generic --generic-ip-address localhost \
  --engine-env HTTP_PROXY=http://192.168.254.10:3128/ \
  --engine-env HTTPS_PROXY=http://192.168.254.10:3128/ \
  --engine-env NO_PROXY=localhost,192.168.2.102,192.168.2.100 \
  --swarm --swarm-master --swarm-discovery \
  token://b54d8665e72939d2c611d8f9e99521b4 swarm-master
  </code></pre>
  
  <p>Result :</p>
  
  <pre><code>Running pre-create checks...
  Creating machine...
  Waiting for machine to be running, this may take a few minutes...
  Machine is running, waiting for SSH to be available...
  Detecting operating system of created instance...
  Provisioning created instance...
  Copying certs to the local machine directory...
  Copying certs to the remote machine...
  Setting Docker configuration on the remote daemon...
  Configuring swarm...
  To see how to connect Docker to this machine, run: docker-machine env swarm-master
  </code></pre>
  
  <p>And I have errors in the logs of the join and manage container (I think the error come because the containers don't take care of the proxy) :</p>
  
  <pre><code>$docker ps
  CONTAINER ID        IMAGE               COMMAND                  CREATED             STATUS              PORTS                              NAMES
  6fbf967cdb60        swarm:latest        "/swarm join --advert"   53 seconds ago      Up 52 seconds       2375/tcp                           swarm-agent
  8b176116989e        swarm:latest        "/swarm manage --tlsv"   54 seconds ago      Up 53 seconds       2375/tcp, 0.0.0.0:3376-&gt;3376/tcp   swarm-agent-master
  
  $docker logs 6fbf967cdb60
  time="2015-11-17T19:37:21Z" level=info msg="Registering on the discovery service every 20s..." addr="localhost:2376" discovery="token://b54d8665e72939d2c611d8f9e99521b4" 
  time="2015-11-17T19:37:41Z" level=error msg="Post https://discovery.hub.docker.com/v1/clusters/b54d8665e72939d2c611d8f9e99521b4?ttl=60: dial tcp: lookup discovery.hub.docker.com on 8.8.4.4:53: read udp 172.17.0.3:46576-&gt;8.8.4.4:53: i/o timeout" 
  
  $docker logs 8b176116989e
  time="2015-11-17T19:37:20Z" level=info msg="Listening for HTTP" addr="0.0.0.0:3376" proto=tcp 
  time="2015-11-17T19:37:40Z" level=error msg="Discovery error: Get https://discovery.hub.docker.com/v1/clusters/b54d8665e72939d2c611d8f9e99521b4: dial tcp: lookup discovery.hub.docker.com on 8.8.4.4:53: read udp 172.17.0.2:44241-&gt;8.8.4.4:53: i/o timeout"
  </code></pre>
  
  <p>Is it a bug of the generic driver ?  </p>
  
  <p>Some others informations :</p>
  
  <pre><code># docker version
   Client:
   Version:      1.9.0
   API version:  1.21
   Go version:   go1.4.2
   Git commit:   76d6bc9
   Built:        Tue Nov  3 17:29:38 UTC 2015
   OS/Arch:      linux/amd64
  
  Server:
   Version:      1.9.0
   API version:  1.21
   Go version:   go1.4.2
   Git commit:   76d6bc9
   Built:        Tue Nov  3 17:29:38 UTC 2015
   OS/Arch:      linux/amd64
  
  # docker info
  Containers: 2
  Images: 8
  Server Version: 1.9.0
  Storage Driver: aufs
   Root Dir: /var/lib/docker/aufs
   Backing Filesystem: extfs
   Dirs: 12
   Dirperm1 Supported: true
  Execution Driver: native-0.2
  Logging Driver: json-file
  Kernel Version: 3.16.0-4-amd64
  Operating System: Debian GNU/Linux 8 (jessie)
  CPUs: 2
  Total Memory: 1000 MiB
  Name: swarm-master
  ID: 6SDE:CQRA:NM6W:TY2H:4DPB:O4YO:IGRT:33AA:OKQP:M6UK:EMSR:H4WR
  WARNING: No memory limit support
  WARNING: No swap limit support
  Labels:
   provider=generic
  </code></pre>
  
  <p>Thank you :)</p>