# Docker设置代理

我们可以为docker-daemon或docker-client设置代理

## docker-daemon

我们可以为docker-daemon同时设置`http_proxy`、`https_proxy`以及`no-proxy`环境变量。直接在`/usr/lib/systemd/system/docker.service`文件的`[Service]`区域添加如下三行即可：

```
[Service]
Environment="HTTP_PROXY=http://proxy.example.com:80/"
Environment="HTTPS_PROXY=http://proxy.example.com:80/"
Environment="NO_PROXY=docker.io,quay.io,192.168.1.100"
```

在实际场景中，我们即需要下载外网的镜像，也需要连上内部的镜像仓库。那么我们可以设置好`HTTP_PROXY`与`HTTPS_PROXY`，使用docker-daemon可以拉外网的镜像。同时设置好在`NO_PROXY`中添加内部镜像仓库的地址。

## docker-client

见Reference

## Reference

* <https://docs.docker.com/config/daemon/systemd/>
* <https://docs.docker.com/network/proxy/>


---

# Agent Instructions: Querying This Documentation

If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter:

```
GET https://pshizhsysu.gitbook.io/docker/dockershe-zhi-dai-li.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
