Merge pull request #519 from docete/issue-518

Add docs of using HTTP/HTTPS proxy

Close #518
pull/520/head
Baohua Yang 2023-01-17 12:03:57 -08:00 committed by GitHub
commit cc683fdb56
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 75 additions and 0 deletions

View File

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