moby: Ubuntu 16.04 http_proxy not work

Output of docker version:

Docker version 1.11.1, build 5604cbe

Output of docker info:

Containers: 2
 Running: 0
 Paused: 0
 Stopped: 2
Images: 1
Server Version: 1.11.1
Storage Driver: aufs
 Root Dir: /var/lib/docker/aufs
 Backing Filesystem: extfs
 Dirs: 6
 Dirperm1 Supported: true
Logging Driver: json-file
Cgroup Driver: cgroupfs
Plugins: 
 Volume: local
 Network: bridge null host
Kernel Version: 4.4.0-22-generic
Operating System: Ubuntu 16.04 LTS
OSType: linux
Architecture: x86_64
CPUs: 8
Total Memory: 7.734 GiB
Name: rooot
ID: 2EOA:RQJS:MIO3:BJA2:UFFW:QMRR:DOSS:6IVG:CAEB:N47O:2VVE:7XFH
Docker Root Dir: /var/lib/docker
Debug mode (client): false
Debug mode (server): false
Registry: https://index.docker.io/v1/
WARNING: No swap limit support

Additional environment details (AWS, VirtualBox, physical, etc.):

Steps to reproduce the issue:

  1. vim /etc/default/docker enable http_proxy
  2. docker pull ubuntu

Describe the results you received: I’m using the http_proxy powered by squid3 publish this issue, but pull image not using proxy.

Describe the results you expected: http_proxy not work

Additional information you deem important (e.g. issue happens only occasionally): socks proxy better the http proxy

About this issue

  • Original URL
  • State: closed
  • Created 8 years ago
  • Comments: 24 (9 by maintainers)

Commits related to this issue

Most upvoted comments

The /etc/default/docker file is only used on systems using sysvinit and upstart (see this comment at the top of the file). Ubuntu 16.04 uses systemd, so doesn’t use that file.

You can use a daemon.json Configuration file, as described here; https://docs.docker.com/engine/reference/commandline/daemon/#daemon-configuration-file

Or a systemd drop-in file, following the instructions here; https://docs.docker.com/engine/admin/systemd/#http-proxy

Just came across the same issue. However, I discovered that /etc/default/docker still works under Ubuntu 16.04 - even when using systemd. The systemd unit file under /lib/systemd/system/docker.service actually configures /etc/default/docker as EnvironmentFile, meaning it gets environment variables from this file.

Put your proxy settings into the file, but leave out the export, e.g.

# Docker Upstart and SysVinit configuration file
[...]
HTTP_PROXY="http://myawesomeproxy/"
HTTPS_PROXY="http://myawesomeproxy/"

Restart the Docker service systemctl docker and you should be fine.

Hello,

I’ve encountered the same proxy issue on a freshly installed ubuntu xenial this weekend but I could only make it work the following way:

root@labint810:~# docker --version
Docker version 1.13.1, build 092cba3
root@labint810:~# lsb_release -a
No LSB modules are available.
Distributor ID:	Ubuntu
Description:	Ubuntu 16.04.2 LTS
Release:	16.04
Codename:	xenial
root@labint810:~# 

I’ve followed the official doc at https://docs.docker.com/engine/admin/systemd/#http-proxy but I was out of luck. Adding this:

[Service]
Environment="HTTP_PROXY=http://proxy.example.com:80/"

to /etc/systemd/system/docker.service.d/http-proxy.conf and reloading systemd just didn’t work.

I kept getting:

root@labint810:~# docker info | grep -i proxy
WARNING: No swap limit support
root@labint810:~# systemctl show --property=Environment docker
Environment=
root@labint810:~# cat /etc/systemd/system/docker.service.d/http-proxy.conf
[Service]
Environment=http_proxy=XXXXXX/
Environment=https_proxy=xxxxxxxx/
root@labint810:~#

So I went to /lib/systemd/system/docker.service and added:

EnvironmentFile=/etc/default/docker

to the [Service] block. I’ve added my proxy config to /etc/default/docker (without EnvironmentFile, config wouldn’t be picked up) without exporting it

root@labint810:~# cat /etc/default/docker 
# Docker Upstart and SysVinit configuration file

#
# THIS FILE DOES NOT APPLY TO SYSTEMD
#
#   Please see the documentation for "systemd drop-ins":
#   https://docs.docker.com/engine/admin/systemd/
#

# Customize location of Docker binary (especially for development testing).
#DOCKERD="/usr/local/bin/dockerd"

# Use DOCKER_OPTS to modify the daemon startup options.
#DOCKER_OPTS="--dns 8.8.8.8 --dns 8.8.4.4"

# If you need Docker to use an HTTP proxy, it can also be specified here.
#export http_proxy="http://127.0.0.1:3128/"

# This is also a handy place to tweak where Docker's temporary files go.
#export DOCKER_TMPDIR="/mnt/bigdrive/docker-tmp"

http_proxy="xxx"
https_proxy="xxx"
HTTP_PROXY="xxx"
HTTPS_PROXY="xxx"
root@labint810:~# 

I restarted docker and now I get the proper config:

root@labint810:~# docker info | grep -i proxy
WARNING: No swap limit support
Http Proxy: http://xxxxx
Https Proxy: http://xxxxxx
root@labint810:~# 

I hope it helps someone as this kept me busy for a few hours.