[issue-518] Add document on how to use HTTP/HTTPS proxy

pull/519/head
Gao Zhenghua 2023-01-16 16:10:32 +08:00 committed by Gao Zhenghua
parent ce4428adfb
commit 13b8e12f44
2 changed files with 75 additions and 0 deletions

View File

@ -75,6 +75,7 @@
* [](advanced_network/bridge.md)
* [](advanced_network/example.md)
* [](advanced_network/config_file.md)
* [ HTTP/HTTPS ](advanced_network/http_https_proxy.md)
* [](advanced_network/ptp.md)
* [Docker Buildx](buildx/README.md)
* [BuildKit](buildx/buildkit.md)

View File

@ -0,0 +1,74 @@
# HTTP/HTTPS
使Docker使 HTTP/HTTPS 使
## dockerd
"docker pull" dockerd dockerd systemd "docker pull" 使 HTTP/HTTPS systemd
- dockerd
```
sudo mkdir -p /etc/systemd/system/docker.service.d
```
- dockerd HTTP/HTTPS /etc/systemd/system/docker.service.d/http-proxy.conf
```
[Service]
Environment="HTTP_PROXY=http://proxy.example.com:8080/"
Environment="HTTPS_PROXY=http://proxy.example.com:8080/"
Environment="NO_PROXY=localhost,127.0.0.1,.example.com"
```
- docker
```
sudo systemctl daemon-reload
sudo systemctl restart docker
```
## docker
使 HTTP/HTTPS docker
- docker ~/.docker/config.json
```
{
"proxies":
{
"default":
{
"httpProxy": "http://proxy.example.com:8080/",
"httpsProxy": "http://proxy.example.com:8080/",
"noProxy": "localhost,127.0.0.1,.example.com"
}
}
}
```
- "docker run"
| | docker run |
| -------- | ---------------- |
| HTTP_PROXY | --env HTTP_PROXY="http://proxy.example.com:8080/" |
| HTTPS_PROXY | --env HTTPS_PROXY="http://proxy.example.com:8080/" |
| NO_PROXY | --env NO_PROXY="localhost,127.0.0.1,.example.com" |
## docker build
使 HTTP/HTTPS "docker build" Dockerfile
- 使 "--build-arg" "docker build"
```
docker build \
--build-arg "HTTP_PROXY=http://proxy.example.com:8080/" \
--build-arg "HTTPS_PROXY=http://proxy.example.com:8080/" \
--build-arg "NO_PROXY=localhost,127.0.0.1,.example.com" .
```
- Dockerfile
| | Dockerfile |
| -------- | ---------------- |
| HTTP_PROXY | ENV HTTP_PROXY="http://proxy.example.com:8080/" |
| HTTPS_PROXY | ENV HTTPS_PROXY="http://proxy.example.com:8080/" |
| NO_PROXY | ENV NO_PROXY="localhost,127.0.0.1,.example.com" |