Skip to content

Put back proxy server content #5951

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Feb 8, 2018
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions _data/toc.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -271,6 +271,8 @@ guides:
title: Docker and iptables
- path: /config/containers/container-networking/
title: Container networking
- path: /network/proxy/
title: Configure Docker to use a proxy server
- sectiontitle: Legacy networking content
section:
- path: /network/links/
Expand Down
5 changes: 5 additions & 0 deletions config/containers/container-networking.md
Original file line number Diff line number Diff line change
Expand Up @@ -63,3 +63,8 @@ settings on a per-container basis.
| `--dns-search` | A DNS search domain to search non-fully-qualified hostnames. To specify multiple DNS search prefixes, use multiple `--dns-search` flags. |
| `--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. |
| `--hostname` | The hostname a container uses for itself. Defaults to the container's name if not specified. |

## Proxy server

If your container needs to use a proxy server, see
[Use a proxy server](/network/proxy.md).
67 changes: 67 additions & 0 deletions network/proxy.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,67 @@
---
title: Configure Docker to use a proxy server
description: How to configure the Docker client to use a proxy server
keywords: network, networking, proxy, client
---

If your container needs to use an HTTP, HTTPS, or FTP proxy server, you can
configure it in different ways:

- In Docker 17.07 and higher, you can
[configure the Docker client](#configure-the-docker-client) to pass
proxy information to containers automatically.

- In Docker 17.06 and lower, you must
[set appropriate environment variables](#use-environment-variables)
within the container. You can do this when you build the image (which makes
the image less portable) or when you create or run the container.

## Configure the Docker client

1. On the Docker client, create or edit the file `~/.docker/config.json` in the
home directory of the user which starts containers. Add JSON such as the
following, substituting the type of proxy with `httpsProxy` or `ftpProxy` if
necessary, and substituting the address and port of the proxy server. You
can configure multiple proxy servers at the same time.

You can optionally exclude hosts or ranges from going through the proxy
server by setting a `noProxy` key to one or more comma-separated IP
addresses or hosts. Using the `*` character as a wildcard is supported, as
shown in this example.

```json
{
"proxies":
{
"default":
{
"httpProxy": "http://127.0.0.1:3001",
"noProxy": "*.test.example.com,.example2.com"
}
}
}
```

Save the file.

2. When you create or start new containers, the environment variables are
set automatically within the container.


## Use environment variables

### Set the environment variables manually

When you build the image, or using the `--env` flag when you create or run the
container, you can set one or more of the following variables to the appropriate
value. This method makes the image less portable, so if you have Docker 17.07
or higher, you should [configure the Docker client](#configure-the-docker-client)
instead.

| Variable | Dockerfile example | `docker run` Example |
|:--------------|:--------------------------------------------------|:----------------------------------------------------|
| `HTTP_PROXY` | `ENV HTTP_PROXY "http://127.0.0.1:3001"` | `--env HTTP_PROXY "http://127.0.0.1:3001"` |
| `HTTPS_PROXY` | `ENV HTTPS_PROXY "https://127.0.0.1:3001"` | `--env HTTPS_PROXY "https://127.0.0.1:3001"` |
| `FTP_PROXY` | `ENV FTP_PROXY "ftp://127.0.0.1:3001"` | `--env FTP_PROXY "ftp://127.0.0.1:3001"` |
| `NO_PROXY` | `ENV NO_PROXY "*.test.example.com,.example2.com"` | `--env NO_PROXY "*.test.example.com,.example2.com"` |