Skip to content

Commit 9c56ec4

Browse files
author
Misty Stanley-Jones
authored
Put back proxy server content (docker#5951)
1 parent 2c35211 commit 9c56ec4

File tree

3 files changed

+74
-0
lines changed

3 files changed

+74
-0
lines changed

_data/toc.yaml

+2
Original file line numberDiff line numberDiff line change
@@ -271,6 +271,8 @@ guides:
271271
title: Docker and iptables
272272
- path: /config/containers/container-networking/
273273
title: Container networking
274+
- path: /network/proxy/
275+
title: Configure Docker to use a proxy server
274276
- sectiontitle: Legacy networking content
275277
section:
276278
- path: /network/links/

config/containers/container-networking.md

+5
Original file line numberDiff line numberDiff line change
@@ -63,3 +63,8 @@ settings on a per-container basis.
6363
| `--dns-search` | A DNS search domain to search non-fully-qualified hostnames. To specify multiple DNS search prefixes, use multiple `--dns-search` flags. |
6464
| `--dns-opt` | A key-value pair representing a DNS option and its value. See your operating system's documentation for `resolv.conf` for valid options. |
6565
| `--hostname` | The hostname a container uses for itself. Defaults to the container's name if not specified. |
66+
67+
## Proxy server
68+
69+
If your container needs to use a proxy server, see
70+
[Use a proxy server](/network/proxy.md).

network/proxy.md

+67
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,67 @@
1+
---
2+
title: Configure Docker to use a proxy server
3+
description: How to configure the Docker client to use a proxy server
4+
keywords: network, networking, proxy, client
5+
---
6+
7+
If your container needs to use an HTTP, HTTPS, or FTP proxy server, you can
8+
configure it in different ways:
9+
10+
- In Docker 17.07 and higher, you can
11+
[configure the Docker client](#configure-the-docker-client) to pass
12+
proxy information to containers automatically.
13+
14+
- In Docker 17.06 and lower, you must
15+
[set appropriate environment variables](#use-environment-variables)
16+
within the container. You can do this when you build the image (which makes
17+
the image less portable) or when you create or run the container.
18+
19+
## Configure the Docker client
20+
21+
1. On the Docker client, create or edit the file `~/.docker/config.json` in the
22+
home directory of the user which starts containers. Add JSON such as the
23+
following, substituting the type of proxy with `httpsProxy` or `ftpProxy` if
24+
necessary, and substituting the address and port of the proxy server. You
25+
can configure multiple proxy servers at the same time.
26+
27+
You can optionally exclude hosts or ranges from going through the proxy
28+
server by setting a `noProxy` key to one or more comma-separated IP
29+
addresses or hosts. Using the `*` character as a wildcard is supported, as
30+
shown in this example.
31+
32+
```json
33+
{
34+
"proxies":
35+
{
36+
"default":
37+
{
38+
"httpProxy": "http://127.0.0.1:3001",
39+
"noProxy": "*.test.example.com,.example2.com"
40+
}
41+
}
42+
}
43+
```
44+
45+
Save the file.
46+
47+
2. When you create or start new containers, the environment variables are
48+
set automatically within the container.
49+
50+
51+
## Use environment variables
52+
53+
### Set the environment variables manually
54+
55+
When you build the image, or using the `--env` flag when you create or run the
56+
container, you can set one or more of the following variables to the appropriate
57+
value. This method makes the image less portable, so if you have Docker 17.07
58+
or higher, you should [configure the Docker client](#configure-the-docker-client)
59+
instead.
60+
61+
| Variable | Dockerfile example | `docker run` Example |
62+
|:--------------|:--------------------------------------------------|:----------------------------------------------------|
63+
| `HTTP_PROXY` | `ENV HTTP_PROXY "http://127.0.0.1:3001"` | `--env HTTP_PROXY "http://127.0.0.1:3001"` |
64+
| `HTTPS_PROXY` | `ENV HTTPS_PROXY "https://127.0.0.1:3001"` | `--env HTTPS_PROXY "https://127.0.0.1:3001"` |
65+
| `FTP_PROXY` | `ENV FTP_PROXY "ftp://127.0.0.1:3001"` | `--env FTP_PROXY "ftp://127.0.0.1:3001"` |
66+
| `NO_PROXY` | `ENV NO_PROXY "*.test.example.com,.example2.com"` | `--env NO_PROXY "*.test.example.com,.example2.com"` |
67+

0 commit comments

Comments
 (0)