Skip to content

Commit 8c8d304

Browse files
authored
Merge pull request docker#13786 from thaJeztah/rewrite_proxy_section
Rewrite section on configuring proxies for containers
2 parents de46ad7 + 073cd2f commit 8c8d304

File tree

2 files changed

+218
-82
lines changed

2 files changed

+218
-82
lines changed

config/daemon/systemd.md

Lines changed: 41 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
---
22
description: Controlling and configuring Docker using systemd
3-
keywords: docker, daemon, systemd, configuration
3+
keywords: dockerd, daemon, systemd, configuration, proxy, networking
44
redirect_from:
55
- /articles/host_integration/
66
- /articles/systemd/
@@ -25,17 +25,34 @@ Docker with systemd. For this, install the two unit files (`service` and
2525
[the github repository](https://github.com/moby/moby/tree/master/contrib/init/systemd)
2626
to `/etc/systemd/system`.
2727

28-
## HTTP/HTTPS proxy
28+
### Configure the Docker daemon to use a proxy server {#httphttps-proxy}
2929

30-
The Docker daemon uses the `HTTP_PROXY`, `HTTPS_PROXY`, and `NO_PROXY`
31-
environmental variables in its start-up environment to configure HTTP or HTTPS
32-
proxy behavior. You can't configure these environment variables using the
33-
`daemon.json` file.
30+
The Docker daemon uses the following environment variables in
31+
its start-up environment to configure HTTP or HTTPS proxy behavior:
3432

35-
This example overrides the default `docker.service` file.
33+
- `HTTP_PROXY`
34+
- `http_proxy`
35+
- `HTTPS_PROXY`
36+
- `https_proxy`
37+
- `NO_PROXY`
38+
- `no_proxy`
39+
40+
In Docker Engine version 23.0 and later versions, you may also configure proxy
41+
behavior for the daemon in the [`daemon.json` file](./index.md#configure-the-docker-daemon):
42+
43+
```json
44+
{
45+
"http-proxy": "http://proxy.example.com:3128",
46+
"https-proxy": "https://proxy.example.com:3129",
47+
"no-proxy": "*.test.example.com,.example.org,127.0.0.0/8"
48+
}
49+
```
50+
51+
These configurations override the default `docker.service` systemd file.
3652

3753
If you are behind an HTTP or HTTPS proxy server, for example in corporate
38-
settings, you need to add this configuration in the Docker systemd service file.
54+
settings, the daemon proxy configurations must be specified in the systemd
55+
service file, not in the `daemon.json` file or using environment variables.
3956

4057
> **Note for rootless mode**
4158
>
@@ -65,24 +82,24 @@ settings, you need to add this configuration in the Docker systemd service file.
6582

6683
```systemd
6784
[Service]
68-
Environment="HTTP_PROXY=http://proxy.example.com:80"
85+
Environment="HTTP_PROXY=http://proxy.example.com:3128"
6986
```
7087

7188
If you are behind an HTTPS proxy server, set the `HTTPS_PROXY` environment
7289
variable:
7390

7491
```systemd
7592
[Service]
76-
Environment="HTTPS_PROXY=https://proxy.example.com:443"
93+
Environment="HTTPS_PROXY=https://proxy.example.com:3129"
7794
```
7895

7996
Multiple environment variables can be set; to set both a non-HTTPS and a
8097
HTTPs proxy;
8198

8299
```systemd
83100
[Service]
84-
Environment="HTTP_PROXY=http://proxy.example.com:80"
85-
Environment="HTTPS_PROXY=https://proxy.example.com:443"
101+
Environment="HTTP_PROXY=http://proxy.example.com:3128"
102+
Environment="HTTPS_PROXY=https://proxy.example.com:3129"
86103
```
87104

88105
> **Note**
@@ -92,7 +109,7 @@ settings, you need to add this configuration in the Docker systemd service file.
92109
>
93110
> ```
94111
> [Service]
95-
> Environment="HTTP_PROXY=http://domain%%5Cuser:complex%%[email protected]:8080/"
112+
> Environment="HTTP_PROXY=http://domain%%5Cuser:complex%%[email protected]:3128/"
96113
> ```
97114
98115
3. If you have internal Docker registries that you need to contact without
@@ -117,8 +134,8 @@ settings, you need to add this configuration in the Docker systemd service file.
117134
118135
```systemd
119136
[Service]
120-
Environment="HTTP_PROXY=http://proxy.example.com:80"
121-
Environment="HTTPS_PROXY=https://proxy.example.com:443"
137+
Environment="HTTP_PROXY=http://proxy.example.com:3128"
138+
Environment="HTTPS_PROXY=https://proxy.example.com:3129"
122139
Environment="NO_PROXY=localhost,127.0.0.1,docker-registry.example.com,.corp"
123140
```
124141
@@ -135,7 +152,7 @@ settings, you need to add this configuration in the Docker systemd service file.
135152
```console
136153
$ sudo systemctl show --property=Environment docker
137154

138-
Environment=HTTP_PROXY=http://proxy.example.com:80 HTTPS_PROXY=https://proxy.example.com:443 NO_PROXY=localhost,127.0.0.1,docker-registry.example.com,.corp
155+
Environment=HTTP_PROXY=http://proxy.example.com:3128 HTTPS_PROXY=https://proxy.example.com:3129 NO_PROXY=localhost,127.0.0.1,docker-registry.example.com,.corp
139156
```
140157

141158
</div>
@@ -152,24 +169,24 @@ settings, you need to add this configuration in the Docker systemd service file.
152169

153170
```systemd
154171
[Service]
155-
Environment="HTTP_PROXY=http://proxy.example.com:80"
172+
Environment="HTTP_PROXY=http://proxy.example.com:3128"
156173
```
157174

158175
If you are behind an HTTPS proxy server, set the `HTTPS_PROXY` environment
159176
variable:
160177

161178
```systemd
162179
[Service]
163-
Environment="HTTPS_PROXY=https://proxy.example.com:443"
180+
Environment="HTTPS_PROXY=https://proxy.example.com:3129"
164181
```
165182

166183
Multiple environment variables can be set; to set both a non-HTTPS and a
167184
HTTPs proxy;
168185

169186
```systemd
170187
[Service]
171-
Environment="HTTP_PROXY=http://proxy.example.com:80"
172-
Environment="HTTPS_PROXY=https://proxy.example.com:443"
188+
Environment="HTTP_PROXY=http://proxy.example.com:3128"
189+
Environment="HTTPS_PROXY=https://proxy.example.com:3129"
173190
```
174191

175192
> **Note**
@@ -179,7 +196,7 @@ settings, you need to add this configuration in the Docker systemd service file.
179196
>
180197
> ```
181198
> [Service]
182-
> Environment="HTTP_PROXY=http://domain%%5Cuser:complex%%[email protected]:8080/"
199+
> Environment="HTTP_PROXY=http://domain%%5Cuser:complex%%[email protected]:3128/"
183200
> ```
184201
185202
3. If you have internal Docker registries that you need to contact without
@@ -204,8 +221,8 @@ settings, you need to add this configuration in the Docker systemd service file.
204221
205222
```systemd
206223
[Service]
207-
Environment="HTTP_PROXY=http://proxy.example.com:80"
208-
Environment="HTTPS_PROXY=https://proxy.example.com:443"
224+
Environment="HTTP_PROXY=http://proxy.example.com:3128"
225+
Environment="HTTPS_PROXY=https://proxy.example.com:3129"
209226
Environment="NO_PROXY=localhost,127.0.0.1,docker-registry.example.com,.corp"
210227
```
211228
@@ -222,7 +239,7 @@ settings, you need to add this configuration in the Docker systemd service file.
222239
```console
223240
$ systemctl --user show --property=Environment docker
224241

225-
Environment=HTTP_PROXY=http://proxy.example.com:80 HTTPS_PROXY=https://proxy.example.com:443 NO_PROXY=localhost,127.0.0.1,docker-registry.example.com,.corp
242+
Environment=HTTP_PROXY=http://proxy.example.com:3128 HTTPS_PROXY=https://proxy.example.com:3129 NO_PROXY=localhost,127.0.0.1,docker-registry.example.com,.corp
226243
```
227244

228245
</div>

0 commit comments

Comments
 (0)