386

I installed Docker on my Ubuntu 13.10 (Saucy Salamander) and when I type in my console:

sudo docker pull busybox

I get the following error:

Pulling repository busybox
2014/04/16 09:37:07 Get https://index.docker.io/v1/repositories/busybox/images: dial tcp: lookup index.docker.io on 127.0.1.1:53: no answer from server

Docker version:

$ sudo docker version

Client version: 0.10.0
Client API version: 1.10
Go version (client): go1.2.1
Git commit (client): dc9c28f
Server version: 0.10.0
Server API version: 1.10
Git commit (server): dc9c28f
Go version (server): go1.2.1
Last stable version: 0.10.0

I am behind a proxy server with no authentication, and this is my /etc/apt/apt.conf file:

Acquire::http::proxy "http://192.168.1.1:3128/";
Acquire::https::proxy "https://192.168.1.1:3128/";
Acquire::ftp::proxy "ftp://192.168.1.1:3128/";
Acquire::socks::proxy "socks://192.168.1.1:3128/";

What am I doing wrong?

Peter Mortensen
  • 30,738
  • 21
  • 105
  • 131
rpayanm
  • 6,303
  • 7
  • 26
  • 39
  • 6
    For the Windows users and boot2docker, see http://stackoverflow.com/a/29303930/6309 – VonC Mar 27 '15 at 15:10
  • 2
    One minor detail: apt does not support SOCKS proxies at all. `Acquire::socks::proxy` means set the proxy for all URLs starting with a `socks` scheme. Since your `sources.list` does not have any `socks://` URLs, that line is entirely ignored. – Hans-Christoph Steiner Dec 16 '15 at 09:14
  • What about ``docker-compose``? – Phoenix Dec 09 '19 at 09:48

28 Answers28

948

Here is a link to the official Docker documentation for proxy HTTP: https://docs.docker.com/config/daemon/systemd/#httphttps-proxy

A quick outline:

First, create a systemd drop-in directory for the Docker service:

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

Now create a file called /etc/systemd/system/docker.service.d/http-proxy.conf that adds the HTTP_PROXY and HTTPS_PROXY environment variables:

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

If you have internal Docker registries that you need to contact without proxying you can specify them via the NO_PROXY environment variable:

Environment="HTTP_PROXY=http://proxy.example.com:80/"
Environment="HTTPS_PROXY=http://proxy.example.com:80/"
Environment="NO_PROXY=localhost,127.0.0.0/8,docker-registry.somecorporation.com"

Flush changes:

$ sudo systemctl daemon-reload

Verify that the configuration has been loaded:

$ sudo systemctl show --property Environment docker
Environment=HTTP_PROXY=http://proxy.example.com:80/
Environment=HTTPS_PROXY=http://proxy.example.com:80/

Restart Docker:

$ sudo systemctl restart docker

Footnote regarding HTTP_PROXY vs. HTTPS_PROXY: for a long time, setting HTTP_PROXY alone has been good enough. But with version 20.10.8, Docker has moved on to Go 1.16, which changes the semantics of this variable: https://golang.org/doc/go1.16#net/http
For https:// URLs, the proxy is now determined by the HTTPS_PROXY variable, with no fallback on HTTP_PROXY.

Thomas GL
  • 13
  • 4
Alexandre Mélard
  • 12,229
  • 3
  • 36
  • 46
  • 3
    This works for Debian Jessie running Docker 1.6.2. Somehow editing `/etc/default/docker` does not work. Maybe I should remove `export` like the one documented for Centos. – neurite Nov 05 '15 at 19:29
  • 2
    For older SysV edit /etc/sysconfig/docker as in https://docs.oracle.com/cd/E37670_01/E37355/html/section_kfy_f2z_fp.html - Oracle Linux 6.7 – SidJ Jan 07 '16 at 03:26
  • 3
    NB: I assumed that 'daemon-reload' would suffice to apply changes to docker, but actually `sudo systemctl restart docker` is strictly required for it to work. – Jose Alban Apr 06 '16 at 08:56
  • 1
    Works for redhat 7, thanks, you saved my day. I tried a lot of proxy settings and only this one works. – Jane Apr 11 '16 at 09:47
  • Thanks for the tip. It helped me understand why docker couldn't download images, while connectivity seemed OK (browser, wget, ...) : the Docker service is run as `root` and I hadn't configured the proxy for `root`! (so obvious, why didn't I see that !) – Stéphane Ch. Apr 18 '16 at 08:24
  • 5
    For ubuntu 14.04 refer @n3o 's answer, Since `systemctl ` is not available for ubuntu 14.04, it uses `upstart` to bring up the services. – chinmay Sep 16 '16 at 12:43
  • 2
    Also in case you want to add a socks proxy, you might want to add this instead: `ALL_PROXY=socks5://:` – John Paraskevopoulos Sep 19 '16 at 08:31
  • Works fine for me Ubuntu 16.04. Thanks – ArafatK Sep 22 '16 at 14:34
  • Worked on OEL7 with 4.1.12 kernel (the one you need for docker). Great reply mate, will reuse the info for sure. Thanks! – sc0p Nov 01 '16 at 17:47
  • 4
    Now it is returning "Proxy Authentication Required"... how to config username and passoword? – pinei Feb 24 '17 at 15:00
  • @pinei I guess it would look like: Environment=HTTP_PROXY=name:password@http://proxy.example.com:80/ – Alexandre Mélard Mar 02 '17 at 09:21
  • Works for me too under centos7 - docker-1.12.6-71.git3e8e77d. Though, I like to use systemctl edit --full docker.service, since I want to be sure it works. And I like the convenience of seeing the full config file while hacking in it. Also, systemctl manage itself the dir creation, and the daemon-reload. Thanks DigitalOceanTeam (digitalocean.com/community/tutorials/…) Merci Alexandre ;) – tisc0 Feb 05 '18 at 20:30
  • 1
    Still working on Debian Stretch. Mans getting mad rep for fixing this one. Cheers boy. – Reverend Tim Apr 16 '18 at 15:34
  • 1
    @AlexandreMélard Your comment about the username:password is correct. I would add that if there are any special characters then you need to use unicode to replace them. For example, for `http://user:p@ssw0rd!@ip:80` you would put `http://user:p%40ssw0rd%21@ip:80`. Tested on Ubuntu 16.04. – RoraΖ Apr 16 '18 at 16:09
  • I tried to fix the half-broken link. Can you review it and see if it is OK (the original page redirects, etc.)? – Peter Mortensen Sep 25 '18 at 10:54
  • This method worked! The ~/.docker/config.json method and other options did not work for me on Docker 1.13 with Redhat 7.6. – Freddie Jan 23 '19 at 16:07
  • Worked on Linux Mint 19.1!! Why setting proxy in `~/.docker/config.json` or as environmental variables doesn't work? – kchomski Mar 04 '19 at 11:39
  • 1
    Success on Fedora 29. Instructions on https://docs.docker.com/network/proxy don't work (350 Downvotes there). – robsch Mar 19 '19 at 12:23
  • First I tried to put an https proxy setting into the same file and that blew it. But with only the http proxy line it works. :) – zslim Feb 05 '20 at 14:24
  • Would it work if the docker is not running as a service. If its installed via binaries – AhmedRana Apr 20 '20 at 12:27
  • Worked on Ubuntu 20.04.1 LTS – GoTTimw Jan 19 '21 at 13:51
  • For docker installed through snap, the folder should be `/etc/systemd/system/snap.docker.dockerd.service.d`, and restart with `sudo systemctl restart snap.docker.dockerd.service` – thetaprime Sep 26 '21 at 01:53
  • Still the correct solution on (k)ubuntu 21.10. I don't understand, why the official solution on docs.docker.com ([link](https://docs.docker.com/network/proxy/)) still doesn't work or is modified. – ChristophS Feb 17 '22 at 12:51
  • in case it helps someone, just as a side comment, it's important that both HTTP and HTTPS vars are defined for this solution to work. – CVname Oct 24 '22 at 16:00
97

Your APT proxy settings are not related to Docker.

Docker uses the HTTP_PROXY environment variable, if present. For example:

sudo HTTP_PROXY=http://192.168.1.1:3128/ docker pull busybox

But instead, I suggest you have a look at your /etc/default/dockerconfiguration file: you should have a line to uncomment (and maybe adjust) to get your proxy settings applied automatically. Then restart the Docker server:

service docker restart
Peter Mortensen
  • 30,738
  • 21
  • 105
  • 131
mbarthelemy
  • 12,465
  • 4
  • 41
  • 43
  • 9
    In my case /etc/default/docker contained lowercased example (http_proxy), but to have things working I had to add uppercased setting (HTTP_PROXY) there. – Mekk Mar 17 '15 at 20:50
  • you shouldn't set the HTTP_PROXY for the docker client – thomas.han Oct 05 '15 at 05:50
  • 3
    Does not work with docker 1.9.1, instead see [this answer](http://stackoverflow.com/a/28093517/2091399) below – Peter Dotchev Dec 08 '15 at 08:05
  • 1
    This works for Ubuntu 14.04 when installing docker from apt.dockerproject.org. – Michael Kopp Jul 25 '16 at 12:39
  • 2
    This does not work on Debian 8.8, and you need to set http_proxy in /etc/systemd/system/docker.service.d as shown in the accepted answer – Roman Mik Jul 18 '17 at 22:02
63

On CentOS the configuration file for Docker is at:

/etc/sysconfig/docker

Adding the below line helped me to get the Docker daemon working behind a proxy server:

HTTP_PROXY="http://<proxy_host>:<proxy_port>"
HTTPS_PROXY="http://<proxy_host>:<proxy_port>"
Peter Mortensen
  • 30,738
  • 21
  • 105
  • 131
Arun Y
  • 931
  • 10
  • 12
50

If you're using the new Docker for Mac (or Docker for Windows), just right-click the Docker tray icon and select Preferences (Windows: Settings), then go to Advanced, and under Proxies specify your proxy settings there. Click Apply and Restart and wait until Docker restarts.

Pablo
  • 77
  • 1
  • 7
Pedro Madrid
  • 1,887
  • 1
  • 20
  • 32
  • In case someone uses a locally-bound proxy (e.g. _127.0.0.1:8787_) on macOS like me, here's the more detailed setup guide: [Why a locally-bound proxy doesn't work](http://stackoverflow.com/a/41544629/2293304) – Rockallite Jan 19 '17 at 01:10
  • 1
    I have set my proxies via windows:settings but these proxies are not propagating to my containers https://stackoverflow.com/questions/48272933/docker-at-windows-10-proxy-propagation-to-containers-not-working – amique Jan 16 '18 at 22:18
  • For me i needed only to put in my DNS Server and it worked then. Thanks. – richin Apr 25 '18 at 14:57
  • Oh thank you this was driving me insane. – Justin Smith Jun 26 '22 at 13:39
31

On Ubuntu you need to set the http_proxy for the Docker daemon, not the client process. This is done in /etc/default/docker (see here).

Peter Mortensen
  • 30,738
  • 21
  • 105
  • 131
gkephorus
  • 1,232
  • 18
  • 31
29

To extend Arun's answer, for this to work in CentOS 7, I had to remove the "export" commands. So edit

/etc/sysconfig/docker

And add:

HTTP_PROXY="http://<proxy_host>:<proxy_port>"
HTTPS_PROXY="https://<proxy_host>:<proxy_port>"
http_proxy="${HTTP_PROXY}"
https_proxy="${HTTPS_PROXY}"

Then restart Docker:

sudo service docker restart

The source is this blog post.

Peter Mortensen
  • 30,738
  • 21
  • 105
  • 131
zummed
  • 291
  • 4
  • 3
14

Why a locally-bound proxy doesn't work

The Problem

If you're running a locally-bound proxy, e.g. listening on 127.0.0.1:8989, it WON'T WORK in Docker for Mac. From the Docker documentation:

I want to connect from a container to a service on the host

The Mac has a changing IP address (or none if you have no network access). Our current recommendation is to attach an unused IP to the lo0 interface on the Mac; for example: sudo ifconfig lo0 alias 10.200.10.1/24, and make sure that your service is listening on this address or 0.0.0.0 (ie not 127.0.0.1). Then containers can connect to this address.

The similar is for Docker server side. (To understand the server side and client side of Docker, try to run docker version.) And the server side runs on a virtualization layer which has its own localhost. Therefore, it won't connect to the proxy server on the localhost of the host OS.

The solution

So, if you're using a locally-bound proxy like me, basically you would have to do the following things to make it work with Docker for Mac:

  1. Make your proxy server listen on 0.0.0.0 instead of 127.0.0.1. Caution: you'll need proper firewall configuration to prevent malicious access to it.

  2. Add a loopback alias to the lo0 interface, e.g. 10.200.10.1/24:

     sudo ifconfig lo0 alias 10.200.10.1/24
    
  3. Set HTTP and/or HTTPS proxy to 10.200.10.1:8989 from Preferences in Docker tray menu (assume that the proxy server is listening on port 8989).

After that, test the proxy settings by running a command in a new container from an image which is not downloaded:

$ docker rmi -f hello-world
  ...

$ docker run hello-world
Unable to find image 'hello-world:latest' locally
latest: Pulling from library/hello-world

c04b14da8d14: Pull complete 
Digest: sha256:0256e8a36e2070f7bf2d0b0763dbabdd67798512411de4cdcf9431a1feb60fd9
Status: Downloaded newer image for hello-world:latest
  ...

Notice: the loopback alias set by ifconfig does not preserve after a reboot. To make it persistent is another topic. Please check this blog post in Japanese (Google Translate may help).

Community
  • 1
  • 1
Rockallite
  • 16,437
  • 7
  • 54
  • 48
  • Thanks for this, I have been trying to find a solution for the last year or so with to get SquidMan on the Mac when trying to access both work and outside network through the company proxy. I got this to stick around by hooking it into launchd to be configured at startup. https://developer.apple.com/library/content/documentation/MacOSX/Conceptual/BPSystemStartup/Chapters/CreatingLaunchdJobs.html – Proctor Jan 20 '17 at 15:25
  • Thank's man. I finally found your post! It works. If you are using cntlm don't forget to add the binding 0.0.0.0 to your configuration. e.g. Listen 0.0.0.0: 8989 – Felix May 15 '17 at 06:56
  • i'm using cntlm too, and change it to gateway mode – Lee Gary Mar 28 '18 at 08:18
13

This is the fix that worked for me: Ubuntu, Docker version: 1.6.2

In the file /etc/default/docker, add the line:

export http_proxy='http://<host>:<port>'

Restart Docker

sudo service docker restart
Peter Mortensen
  • 30,738
  • 21
  • 105
  • 131
n3o
  • 2,795
  • 5
  • 24
  • 37
10

To configure Docker to work with a proxy you need to add the HTTPS_PROXY / HTTP_PROXY environment variable to the Docker sysconfig file (/etc/sysconfig/docker).

Depending on if you use init.d or the services tool you need to add the "export" statement (due to Debian Bug report logs - #767441. Examples in /etc/default/docker are misleading regarding the supported syntax):

HTTPS_PROXY="https://<user>:<password>@<proxy-host>:<proxy-port>"
HTTP_PROXY="https://<user>:<password>@<proxy-host>:<proxy-port>"
export HTTP_PROXY="https://<user>:<password>@<proxy-host>:<proxy-port>"
export HTTPS_PROXY="https://<user>:<password>@<proxy-host>:<proxy-port>"

The Docker repository (Docker Hub) only supports HTTPS. To get Docker working with SSL intercepting proxies you have to add the proxy root certificate to the systems trust store.

For CentOS, copy the file to /etc/pki/ca-trust/source/anchors/ and update the CA trust store and restart the Docker service.

If your proxy uses NTLMv2 authentication - you need to use intermediate proxies like Cntlm to bridge the authentication. This blog post explains it in detail.

Peter Mortensen
  • 30,738
  • 21
  • 105
  • 131
6

After installing Docker, do the following:

[mdesales@pppdc9prd1vq ~]$ sudo HTTP_PROXY=http://proxy02.ie.xyz.net:80 ./docker -d &
[2] 20880

Then, you can pull or do anything:

mdesales@pppdc9prd1vq ~]$ sudo docker pull base
2014/04/11 00:46:02 POST /v1.10/images/create?fromImage=base&tag=
[/var/lib/docker|aa088847] +job pull(base, )
Pulling repository base
b750fe79269d: Download complete
27cf78414709: Download complete
[/var/lib/docker|aa088847] -job pull(base, ) = OK (0)
Peter Mortensen
  • 30,738
  • 21
  • 105
  • 131
Marcello DeSales
  • 21,361
  • 14
  • 77
  • 80
5

In the new version of Docker, docker-engine, in a systemd based distribution, you should add the environment variable line to /lib/systemd/system/docker.service, as it is mentioned by others:

Environment="HTTP_PROXY=http://hostname_or_ip:port/"
Peter Mortensen
  • 30,738
  • 21
  • 105
  • 131
Mehdi Hamidi
  • 99
  • 1
  • 8
4

As I am not allowed to comment yet:

For CentOS 7 I needed to activate the EnvironmentFile within "docker.service" like it is described here: Control and configure Docker with systemd.

Edit: I am adding my solution as stated out by Nilesh. I needed to open "/etc/systemd/system/docker.service" and I had to add within the section

[Service]

EnvironmentFile=-/etc/sysconfig/docker

Only then was the file "etc/sysconfig/docker" loaded on my system.

Peter Mortensen
  • 30,738
  • 21
  • 105
  • 131
4

If using socks5 proxy, here is my test with Docker 17.03.1-ce with setting "all_proxy", and it worked:

# Set up socks5 proxy server
ssh sshUser@proxyServer -C -N -g -D \
     proxyServerIp:9999 \
     -o ExitOnForwardFailure=yes \
     -o ServerAliveInterval=60

# Configure dockerd and restart.
# NOTICE: using "all_proxy"
mkdir -p /etc/systemd/system/docker.service.d
cat > /etc/systemd/system/docker.service.d/http-proxy.conf <<EOF
[Service]
Environment="all_proxy=socks5://proxyServerIp:9999"
Environment="NO_PROXY=localhost,127.0.0.1,private.docker.registry.com"
EOF

systemctl daemon-reload
systemctl restart docker

# Test whether can pull images
docker run -it --rm alpine:3.5
Peter Mortensen
  • 30,738
  • 21
  • 105
  • 131
btpka3
  • 3,720
  • 2
  • 23
  • 26
3

To solve the problem with curl in Docker build, I added the following inside the Dockerfile:

ENV http_proxy=http://infoprx2:8080
ENV https_proxy=http://infoprx2:8080
RUN apt-get update && apt-get install -y curl vim

Note that the ENV statement is BEFORE the RUN statement.

And in order to make the Docker daemon able to access the Internet (I use Kitematic with boot2docker), I added the following into /var/lib/boot2docker/profile:

export HTTP_PROXY=http://infoprx2:8080
export HTTPS_PROXY=http://infoprx2:8080

Then I restarted Docker with sudo /etc/init.d/docker restart.

Peter Mortensen
  • 30,738
  • 21
  • 105
  • 131
Bruno Negrão Zica
  • 764
  • 2
  • 7
  • 16
3

The complete solution for Windows, to configure the proxy settings.

< user>:< password>@< proxy-host>:< proxy-port>

You can configure it directly by right-clicking on settings, in the Docker icon, and then Proxies.

There you can configure the proxy address, port, user name, and password.

In this format:

< user>:< password>@< proxy-host>:< proxy-port>

Example:

"geronimous:mypassword@192.168.44.55:8080"

Nothing more than this.

Peter Mortensen
  • 30,738
  • 21
  • 105
  • 131
2

If you are on Ubuntu, you should execute this command:

export https_proxy=http://your_name:password@ip_proxy:port docker 

And reload Docker with:

service docker.io restart

Or go to /etc/docker.io with nano...

Peter Mortensen
  • 30,738
  • 21
  • 105
  • 131
koff75
  • 99
  • 1
  • 12
2

Perhaps you need to set up lowercase variables. In my case, my /etc/systemd/system/docker.service.d/http-proxy.conf file looks like this:

[Service]
Environment="ftp_proxy=http://<user>:<password>@<proxy_ip>:<proxy_port>/"
Environment="http_proxy=http://<user>:<password>@<proxy_ip>:<proxy_port>/"
Environment="https_proxy=http://<user>:<password>@<proxy_ip>:<proxy_port>/"

Good luck! :)

Peter Mortensen
  • 30,738
  • 21
  • 105
  • 131
2

If you're in Ubuntu, execute these commands to add your proxy.

sudo nano /etc/default/docker

And uncomment the lines that specifies

#export http_proxy = http://username:password@10.0.1.150:8050

And replace it with your appropriate proxy server and username.

Then restart Docker using:

service docker restart

Now you can run Docker commands behind proxy:

docker search ubuntu
Peter Mortensen
  • 30,738
  • 21
  • 105
  • 131
Gary Mendonca
  • 1,925
  • 1
  • 13
  • 21
2

I was also facing the same issue behind a firewall. Follow the below steps:

$ sudo vim /etc/systemd/system/docker.service.d/http_proxy.conf
[Service]
Environment="HTTP_PROXY=http://username:password@IP:port/"

Don’t use or remove the https_prxoy.conf file.

Reload and restart your Docker container:

$ sudo systemctl daemon-reload
$ sudo systemctl restart docker
$ docker pull hello-world
Using default tag: latest
latest: Pulling from library/hello-world
1b930d010525: Pull complete
Digest: sha256:2557*********************************8
Status: Downloaded newer image for hello-world:latest
Peter Mortensen
  • 30,738
  • 21
  • 105
  • 131
Abhishek
  • 153
  • 1
  • 2
  • 11
1

Simply setting proxy environment variables did not help me in version 1.0.1... I had to update the /etc/default/docker.io file with the correct value for the "http_proxy" variable.

Peter Mortensen
  • 30,738
  • 21
  • 105
  • 131
Richil
  • 141
  • 1
  • 3
1

On Ubuntu 14.04 (Trusty Tahr) with Docker 1.9.1, I just uncommented the http_proxy line, updated the value and then restarted the Docker service.

export http_proxy="http://proxy.server.com:80"

and then

service docker restart
Peter Mortensen
  • 30,738
  • 21
  • 105
  • 131
Neo
  • 4,640
  • 5
  • 39
  • 53
1

Remove proxy from environment variables

unset http_proxy
unset https_proxy
unset no_proxy

and then restart your docker

shivam
  • 489
  • 2
  • 8
  • 22
0

Try this:

sudo HTTP_PROXY=http://<IP address of proxy server:port> docker -d & 
Peter Mortensen
  • 30,738
  • 21
  • 105
  • 131
Abdennour TOUMI
  • 87,526
  • 38
  • 249
  • 254
0

On RHEL6.6 only this works (note the use of export):

/etc/sysconfig/docker

export http_proxy="http://myproxy.example.com:8080"
export https_proxy="http://myproxy.example.com:8080"

NOTE: Both can use the http protocol.)

Thanks to https://crondev.com/running-docker-behind-proxy/

vaughan
  • 6,982
  • 6
  • 47
  • 63
0

In my network, Ubuntu works behind a corporate ISA proxy server. And it requires authentication. I tried all the solutions mentioned above and nothing helped. What really helped was to write a proxy line in file /etc/systemd/system/docker.service.d/https-proxy.conf without a domain name.

Instead of

Environment="HTTP_PROXY=http://user@domain:password@proxy:8080"

or

Environment="HTTP_PROXY=http://domain\user:password@proxy:8080"

and some other replacement such as @ -> %40 or \ -> \\ I tried to use

Environment="HTTP_PROXY=http://user:password@proxy:8080"

And it works now.

Peter Mortensen
  • 30,738
  • 21
  • 105
  • 131
Dzmitry Paliakou
  • 1,587
  • 19
  • 27
0

This doesn't exactly answer the question, but might help, especially if you don't want to deal with service files.

In case you are the one is hosting the image, one way is to convert the image as a tar archive instead, using something like the following at the server.

docker save <image-name> --output <archive-name>.tar

Simply download the archive and turn it back into an image.

docker load <archive-name>.tar
nomad
  • 471
  • 6
  • 12
0

Have resolved the issue by following the below steps:

step 1: sudo systemctl start docker

step 2: sudo systemctl enable docker
(Created symlink from /etc/systemd/system/multi-user.target.wants/docker.service to /usr/lib/systemd/system/docker.service.)

step 3: sudo systemctl status docker

step 4: sudo mkdir -p /etc/systemd/system/docker.service.d

step 5: sudo vi /etc/systemd/system/docker.service.d/proxy.conf

Set proxy as below

[Service]

Environment="HTTP_PROXY=http://proxy.server.com:80"

Environment="HTTPS_PROXY=http://proxy.server.com:80"

Environment="NO_PROXY=.proxy.server.com,*.proxy.server.com,localhost,127.0.0.1,::1"

step 6: sudo systemctl daemon-reload

step 7: sudo systemctl restart docker.service

step 8: vi /etc/environment and source /etc/environment

http_proxy=http://proxy.server.com:80
https_proxy=http://proxy.server.com:80
ftp_proxy=http://proxy.server.com:80
no_proxy=127.0.0.1,10.0.0.0/8,3.0.0.0/8,localhost,*.abc.com
The Godfather
  • 4,235
  • 4
  • 39
  • 61
0

I had a problem like I needed to use proxy to use google's dns for project's dependency and for API request needed to communicate with a private server at the same time.

For RHEL7 I configured the system like this:

went to the directory /etc/sysconfig/docker

Environment=http_proxy="http://ip:port"
Environment=https_proxy="http://ip:port"
Environment=no_proxy="hostname"

then save the file and use the command :

sudo systemctl restart docker

after that configure your Dockerfile : setup the environment structure first:

ENV http_proxy http://ip:port
ENV https_proxy http://ip:port
ENV no_proxy "hostname"

that's all! :)

Raisul
  • 366
  • 1
  • 11