Docker Community Forums

Share and learn in the Docker community.

Beginner having trouble with docker behind company proxy

I’m using DockerToolbox-1.8.3 on a Mac. From home, I’m not having any problems but from work where I am behind a company proxy, I’m having network connectivity problems. I’m using cntlm if that is relevant to anyone.

I’m following the getting started documentation for docker. At the step:

$ docker run hello-world

I get:

Network timed out while trying to connect to … images. You may want to check your internet connection or if you are behind a proxy.

After that I tried:

docker-machine create -d virtualbox --engine-env
HTTP_PROXY=/ --engine-env
HTTPS_PROXY= default

This time when I invoke:

$ docker run hello-world, I get:

Error while pulling image: Get http: error connecting to proxy http://localhost:3128/: dial tcp connection refused

I’ve spent a lot of time trying to figure this out but with no luck. Getting pretty frustrated. Any help would be immensely appreciated. Thanks!!

It looks like you are running a proxy on on your host. The Virtual machine that docker-machine creates has its own that isn’t running a proxy. When docker tries to connect, it gets connection refused.


Hi Jeff,

Thanks a lot for your help.

You are correct. I am using cntlm ( as an
interface to NTLM. cntlm creates a proxy that runs on localhost. On a mac,
I don’t know how to make terminal programs get past NTLM without using

So, I guess the question now becomes how to use Docker on a mac where cntlm
is installed.

Your help is greatly appreciated.



The trick here is to run cntlm in gateway mode instead of cntlm listening only on localhost ( If you run cntlm --help you can see the gateway option.

-g  Gateway mode - listen on all interfaces, not only loopback.

So you can run cntlm in gateway mode, either by running cntlm -g or making changes to cntlm.conf to run cntlm always in gateway mode

So once cntlm listens on all interface you can give the ip address of your machines interface that is connected to your office network as the proxy host. As the machine created using docker-machine has a virtualbox nat interface, it can connect to cntlm without any issues.

Please let me know if you need any more help on this.


Hi Ranjandas,

I tried your suggestions but the results unfortunately were the same. Here’s what I did:

  1. Modified my cntlm.conf file to turn the gateway flag on.
  2. Created a new default with:

docker-machine create -d virtualbox
–engine-env HTTP_PROXY=http://localhost:3128/
–engine-env HTTPS_PROXY=http://localhost:3128/ default

After doing this, when I invoke:

~ $ docker run hello-world

I still get:

~ $ docker run hello-world
Unable to find image ‘hello-world:latest’ locally
Pulling repository
Error while pulling image: Get http: error connecting to proxy http://localhost:3128/: dial tcp connection refused

I suspect that I haven’t fully understood your instructions. Maybe I just need another nudge in the right direction.


since you have configured cntlm to listen to all your host’s IPs, you can connect to something other than

Here’s an overview of the typical virtualbox networking setup (skip to the end if you want a tldr):

Say my laptop running virtualbox and cntlm has three IPs: (lo0), (en0), and (vboxnet1). The exact IPs and interface names will vary with the exact setup, so double check yours using ifconfig.

My boot2docker VM is running as well, but it has its own network stack. In addition to the VM having its own (lo), it’ll have another address like (eth0), and (eth1).

The eth0 on the VM is running with a virtualbox “NAT mode” network. From the point of view of my host, any connections coming through this interface just look like the virtualbox process on the host are making them directly. From the point of view of the VM, it’s a network with a gateway ip ( I can double check this by looking at the default route by running the route command from inside the VM. The boot2docker VM will direct all its traffic through this interface by default.

The eth1 on the VM is running a “host only network”. There is no router/gateway configured on this interface. essentially the virtual interface in the VM is bridged with the vboxnet1 interface on my host. This is the IP that is returned if you run the docker-machine ip default command.

So, if I’m on the VM, and I want to reach the host, I have two main options.

  • I can connect to the host’s real ip on the network ( on en0 in the above example).
  • I can connect to the host’s ip on the vboxnet1 interface ( using the host-only networking mode.

The reason that you are getting connection refused still is that the VM still has its own, and any time you connect to you are connecting to yourself-- the VM in this case.

tldr; probably HTTP_PROXY= will work.


Oh yeah! I forgot about another virtualbox trick!

The IP address that is the default gateway for a NAT mode interface will forward to the host’s


I can set up something that listens only on my host’s, and then access it from the VM by hitting

Here’s some official docs on virtualbox’s networking modes as well:

1 Like

Thanks a ton, Jeff. I tried your “tldr;” and it worked!!! I’ll study your network related explanation so that I understand the fix better, but I can see your expertise far exceeds mine in this area.

Thanks, again!!


Hi Jeff,

Well, I’m broke again. I’m trying to work from home this afternoon. I am connected to my wireless network at home and VPN’ed to my work environment. I’m still running cntlm. I suppose that I need to configure a new machine for home use but I don’t know how to do that. I’ll start poking around to see if I can figure it out.

Any pointers would be greatly appreciated.


The virtualbox NAT network by default will populate your exact DNS resolver from /etc/resolve.conf into the VM. If you change networks, this isn’t automatically updated. The easiest way to deal with it is to reboot the VM if you switch networks.

1 Like

Set proxy ip as ‘’, works for me. Thank you.

I have followed above steps to replicate this issue in my end, but no luck. could you please help me out on this.

$ sudo docker run hello-world
Unable to find image ‘hello-world:latest’ locally
docker: Error response from daemon: Get http: error connecting to proxy dial tcp getsockopt: connection refused.
See ‘docker run --help’.

i have configured the /etc/default/docker file in my end as well. plz find below for the same.

If you need Docker to use an HTTP proxy, it can also be specified here.

export http_proxy=""
export https_proxy=“

please suggest me.