1
1
---
2
2
description : Controlling and configuring Docker using systemd
3
- keywords : docker , daemon, systemd, configuration
3
+ keywords : dockerd , daemon, systemd, configuration, proxy, networking
4
4
redirect_from :
5
5
- /articles/host_integration/
6
6
- /articles/systemd/
@@ -25,17 +25,34 @@ Docker with systemd. For this, install the two unit files (`service` and
25
25
[ the github repository] ( https://github.com/moby/moby/tree/master/contrib/init/systemd )
26
26
to ` /etc/systemd/system ` .
27
27
28
- ## HTTP/HTTPS proxy
28
+ ### Configure the Docker daemon to use a proxy server {#httphttps-proxy}
29
29
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:
34
32
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.
36
52
37
53
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.
39
56
40
57
> ** Note for rootless mode**
41
58
>
@@ -65,24 +82,24 @@ settings, you need to add this configuration in the Docker systemd service file.
65
82
66
83
``` systemd
67
84
[Service]
68
- Environment="HTTP_PROXY=http://proxy.example.com:80 "
85
+ Environment="HTTP_PROXY=http://proxy.example.com:3128 "
69
86
```
70
87
71
88
If you are behind an HTTPS proxy server, set the ` HTTPS_PROXY ` environment
72
89
variable:
73
90
74
91
``` systemd
75
92
[Service]
76
- Environment="HTTPS_PROXY=https://proxy.example.com:443 "
93
+ Environment="HTTPS_PROXY=https://proxy.example.com:3129 "
77
94
```
78
95
79
96
Multiple environment variables can be set; to set both a non-HTTPS and a
80
97
HTTPs proxy;
81
98
82
99
``` systemd
83
100
[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 "
86
103
```
87
104
88
105
> ** Note**
@@ -92,7 +109,7 @@ settings, you need to add this configuration in the Docker systemd service file.
92
109
>
93
110
> ```
94
111
> [Service]
95
- > Environment="HTTP_PROXY=http://domain%%5Cuser:complex%%[email protected] :8080 /"
112
+ > Environment="HTTP_PROXY=http://domain%%5Cuser:complex%%[email protected] :3128 /"
96
113
> ```
97
114
98
115
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.
117
134
118
135
```systemd
119
136
[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 "
122
139
Environment="NO_PROXY=localhost,127.0.0.1,docker-registry.example.com,.corp"
123
140
```
124
141
@@ -135,7 +152,7 @@ settings, you need to add this configuration in the Docker systemd service file.
135
152
``` console
136
153
$ sudo systemctl show --property=Environment docker
137
154
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
139
156
```
140
157
141
158
</div >
@@ -152,24 +169,24 @@ settings, you need to add this configuration in the Docker systemd service file.
152
169
153
170
``` systemd
154
171
[Service]
155
- Environment="HTTP_PROXY=http://proxy.example.com:80 "
172
+ Environment="HTTP_PROXY=http://proxy.example.com:3128 "
156
173
```
157
174
158
175
If you are behind an HTTPS proxy server, set the ` HTTPS_PROXY ` environment
159
176
variable:
160
177
161
178
``` systemd
162
179
[Service]
163
- Environment="HTTPS_PROXY=https://proxy.example.com:443 "
180
+ Environment="HTTPS_PROXY=https://proxy.example.com:3129 "
164
181
```
165
182
166
183
Multiple environment variables can be set; to set both a non-HTTPS and a
167
184
HTTPs proxy;
168
185
169
186
``` systemd
170
187
[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 "
173
190
```
174
191
175
192
> ** Note**
@@ -179,7 +196,7 @@ settings, you need to add this configuration in the Docker systemd service file.
179
196
>
180
197
> ```
181
198
> [Service]
182
- > Environment="HTTP_PROXY=http://domain%%5Cuser:complex%%[email protected] :8080 /"
199
+ > Environment="HTTP_PROXY=http://domain%%5Cuser:complex%%[email protected] :3128 /"
183
200
> ```
184
201
185
202
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.
204
221
205
222
```systemd
206
223
[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 "
209
226
Environment="NO_PROXY=localhost,127.0.0.1,docker-registry.example.com,.corp"
210
227
```
211
228
@@ -222,7 +239,7 @@ settings, you need to add this configuration in the Docker systemd service file.
222
239
``` console
223
240
$ systemctl --user show --property=Environment docker
224
241
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
226
243
```
227
244
228
245
</div >
0 commit comments