-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
2 changed files
with
43 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,42 @@ | ||
--- | ||
title: Docker通过代理拉取镜像 | ||
date: 2024-11-25 | ||
author: chensino | ||
publish: true | ||
isOriginal: false | ||
--- | ||
|
||
:::note 转载 | ||
<https://cloud.tencent.com/developer/article/1806455> | ||
::: | ||
|
||
### 背景 | ||
|
||
> docker官方源被屏蔽,国内用户无法直接拉取镜像,很多国内的镜像源又不稳定,还是想用官方源,这里提供http代理的方式下载官方源, | ||
> 当然还有其他系统全局代理,网关代理等等不在本次讨论范围,本次使用http代理docker的pull,从官方获取镜像 | ||
### 配置 | ||
|
||
在执行`docker pull`时,是由守护进程dockerd来执行。因此,代理需要配在dockerd的环境中。而这个环境,则是受systemd所管控,因此实际是systemd的配置。 | ||
|
||
~~~shell | ||
sudo mkdir -p /etc/systemd/system/docker.service.d | ||
sudo touch /etc/systemd/system/docker.service.d/proxy.conf | ||
~~~ | ||
|
||
在proxy.conf配置如下内容,改成自己的http代理地址 | ||
|
||
~~~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" | ||
~~~ | ||
|
||
### 重启生效 | ||
|
||
~~~shell | ||
sudo systemctl daemon-reload | ||
sudo systemctl restart docker | ||
~~~ | ||
|