Skip to content

Commit

Permalink
给docker pull设置代理
Browse files Browse the repository at this point in the history
  • Loading branch information
ChenSino committed Nov 25, 2024
1 parent 7580740 commit a87637b
Show file tree
Hide file tree
Showing 2 changed files with 43 additions and 1 deletion.
2 changes: 1 addition & 1 deletion docs/.vuepress/navbar.ts
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ export default navbar([
{ text: "ES5", icon: "javascript", link: "es5/" },
{ text: "ES6", icon: "javascript", link: "es6/" },
{ text: "TypeScript", icon: "javascript", link: "typeScript/" },
{ text: "NodeJS", icon: "nodejs", link: "nodejs/" },
{ text: "NodeJS", icon: "node", link: "nodejs/" },
]
},
{
Expand Down
42 changes: 42 additions & 0 deletions docs/other/docker/通过代理拉取镜像.md
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
~~~

0 comments on commit a87637b

Please sign in to comment.