Skip to content

Instantly share code, notes, and snippets.

What would you like to do?

The Docker Engine is a highly configurable software product, and can sometimes be complicated. These tips are put together to help users setup docker to work inside a networked proxy.


Docker Toolbox Users

Docker Toolbox is now the legacy offering from Docker for platforms that are not supported by Docker for Windows and Docker for Mac.

Docker Toolbox is the most common method for installing docker on Mac and Windows systems. You can find instructions for download and install on the docker website. When using the docker engine under toolbox, Docker will install a small virtual machine (boot2docker) using VirtualBox, that is used to run the Docker Host Engine.

Configure your proxies manually

You can use a proxy close to use, for example:

  1. Open a command prompt and connect to the default virtual machine using docker-machine.

    $ docker-machine ssh default
  2. Edit the /var/lib/boot2docker/profile file to add the registry, become root with sudo -i command.

    # Setup proxy
    export HTTP_PROXY=
    export HTTPS_PROXY=
    export no_proxy="/var/run/docker.sock,localaddress,localhost,,,,,"
    export DOCKER_TLS=no
  3. Restart the docker service:

    $ sudo service docker restart

Configure proxies with docker-machine

On windows host running docker toolbox, it's possible to use docker-machine to automatically configure your boot2docker image with proper proxy settings. Here are some quick steps on how to use docker-machine to perform this action.

  1. Open a cygwin shell prompt or equivalent bash shell prompt on your windows system. If you do not have one yet, you can also use the GitHub Enterprise Desktop to get a mintty shell prompt with these capabilities from here: Run these commands in your prompt:

    export HTTP_PROXY=
    export HTTPS_PROXY=
    export NO_PROXY=/var/run/docker.sock,localaddress,localhost,,,,,
    export http_proxy=
    export https_proxy=
    export no_proxy=/var/run/docker.sock,localaddress,localhost,,,,,
  2. In the same shell prompt, you can now remove the pre-existing default machine that was setup in VirtualBox. Note, this will delete all containers from your virtual machine.

    docker-machine rm default
  3. Recreate the default machine, but this time we can specify all the proxy options:

    docker-machine create -d virtualbox \
     --engine-env HTTP_PROXY="$HTTP_PROXY" \
     --engine-env HTTPS_PROXY="$HTTPS_PROXY" \
     --engine-env NO_PROXY="$NO_PROXY" \
     --engine-env http_proxy="$https_proxy" \
     --engine-env https_proxy="$https_proxy" \
     --engine-env no_proxy="$no_proxy" \

    Optionally include these options to adjust the Virtual machine resources.

    --virtualbox-cpu-count 4  \
    --virtualbox-memory 4096  \
    --virtualbox-disk-size 90000 \
    --virtualbox-no-vtx-check \

Docker engine on Linux INIT V5

  • Edit /etc/default/docker

    # Setup proxy
    export http_proxy=""
    export https_proxy=""
    export no_proxy="/var/run/docker.sock,localaddress,localhost,,,,,"
  • Restart docker: sudo service docker restart

Docker engine on Linux running new Systemd services

Run the following commands:

sudo mkdir /etc/systemd/system/docker.service.d
sudo /bin/bash -c 'cat <<EOF > /etc/systemd/system/docker.service.d/proxy.conf
Environment="HTTP_PROXY=" \
"NO_PROXY=/var/run/docker.sock,localaddress,localhost,,,,," \
"http_proxy=" \
"https_proxy=" \
sudo systemctl daemon-reload
sudo systemctl restart docker

Docker for Windows

Docker for Windows is the current offering from Docker to run Docker on Windows. Docker for Windows requires Windows 10 Professional or Enterprise and Hyper-V.

Docker for Windows creates a Hyper-V VM that runs MobyLinux. Your Docker containers run in the Hyper-V VM.


Before installation, ensure Hyper-V is enabled in your BIOS and you have enabled Hyper-V in Windows Features.

At the end of installation, Docker may ask to make changes to your BIOS - say no. There are some conflicts with Bitlocker and your TPM/BIOS may get corrupted - possibly requiring a re-image. Manually make the Hyper-V changes mentioned above.

You can find Docker for Windows Installation here. This provides best experience on Windows for running Linux based containers.

Proxy Settings

Complete these steps before you attempt to use Docker. If you have not configured the web proxies Docker will be able to download container images.

When is reported Docker as running, you can right click the whale in notifications and select Settings. Choose Proxies, select Use proxy server and enter the URLs for the "local" proxy servers. The following examples show the proxy servers.

These will then be passed down to Docker and any containers started. Note: skipping the http(s) prefixes, can cause problems for Ubuntu apt-get.

Enter in the "Bypass proxy settings for these Hosts & Domains" text field.

Click on the Apply button, Docker (the Hyper-V VM) will restart. This will take some time on the standard issue laptops. Wait for Docker to restart.

If you navigate away for the Networking "tab", your changes will be discarded.

Select the "Docker Daemon" settings tab. Enter the URL for your registry hub ("") in the "registry-mirrors" field. The text field will run syntax-checks on your changes. The field should now read thus.

  "registry-mirrors": [

Apply your changes by clicking the Apply button. Docker will restart.

You can control the share of memory and CPU assigned to Docker on the Advanced "tab" of the Docker Settings tool.

McAfee Firewall Issues

When sharing a PC drive with Docker (Settings / Shared Drives), you may get a firewall error message (McAfee log - Block NetBIOS TCP incoming). Since we cannot easily affect the McAfee rules, here is a workaround...

Go to Settings / Network and set the Subnet Address to the same as your PC (it is probably the default Example: PC IP is, set to Press apply and when Docker has restarted you should be able to share a PC drive with Docker. Note: this solution will cause Docker to be assigned the IP x.x.x.1 which could cause IP conflicts. It is not clear how visible this IP is outside of your machine. Any other suggestions would be appreciated.

Docker Native Windows Containers

See this article on MSDN to install native Docker on Windows server.

Below are instructions to make it work your proxy network.

Setup proxy settings

# Configure HTTP proxy for Invoke-WebRequest
$reg = "HKCU:\Software\Microsoft\Windows\CurrentVersion\Internet Settings"
Set-ItemProperty -Path $reg -Name ProxyServer -Value ""
Set-ItemProperty -Path $reg -Name ProxyEnable -Value 1

### Configure HTTP proxy for Docker so it's able to pull images
[Environment]::SetEnvironmentVariable("HTTP_PROXY", "", [EnvironmentVariableTarget]::Machine)
[Environment]::SetEnvironmentVariable("HTTPS_PROXY", "", [EnvironmentVariableTarget]::Machine)

Install Docker

  1. Enable containers feature with command:

    Install-WindowsFeature containers
  2. Restart computer

    Restart-Computer -Force
  3. Install docker from nuget packages

    Install-PackageProvider -Name NuGet -MinimumVersion -Force
    Install-Module -Name DockerMsftProvider -Force
    Install-Package -Name docker -ProviderName DockerMsftProvider -Force
    # For persistent use, will apply even after a reboot.
    [Environment]::SetEnvironmentVariable("Path", $env:Path + ";C:\Program Files\Docker", [EnvironmentVariableTarget]::Machine)
    Restart-Computer -Force
  4. Install Base Container

    docker pull microsoft/nanoserver
    docker pull microsoft/windowsservercore

Run a Native windows container

# And finally run windows command prompt in a container
docker run --rm windowsservercore cmd


Docker for Mac

You can find Docker for Mac installation here. This provides best experience on Mac OS for running Linux based containers.

Contributions welcome

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment