ubuntu为Docker配置代理

终端代理

我们平常在ubuntu终端中使用curl或git命令时,往往会很慢。

所以,首先需要给ubuntu终端环境添加代理。

查看自身那个软件的端口号,我这里是7890。

bash 复制代码
sudo gedit ~/.bashrc

export http_proxy='http://localhost:7890'
export https_proxy='http://localhost:7890'

Docker 代理

在国内拉取 Docker 中央仓库的镜像本来就速度就一直比较慢,近期就更慢了,基本处于一个不可达的状态。当然我们可以通过设置国内一些加速镜像器来加速镜像下载。但是国内镜像不全,更新也不及时,如果你要下载的镜像国内加速器上没有的话,你最终还是要 Docker 中央仓库镜像去下载。

shell 复制代码
sudo mkdir -p /etc/systemd/system/docker.service.d

vim /etc/systemd/system/docker.service.d/http-proxy.conf

在http-proxy.conf文件中写入

bash 复制代码
[Service]
Environment="HTTP_PROXY=http://localhost:7777"
Environment="HTTPS_PROXY=http://localhost:7777"
复制代码
注意: HTTP_PROXY 用于代理访问 http 请求,HTTPS_PROXY 用于代理访问 https 请求,如果想某个 IP或域名不走代理则配置到 NO_PROXY中。

重启Docker服务

bash 复制代码
sudo systemctl daemon-reload
sudo systemctl restart docker

参考

一文讲透如何给Docker设置代理

相关推荐
辉的技术笔记14 小时前
Dify 自部署为什么跑不动?6 层瓶颈诊断法教你定位
docker
orion571 天前
Missing Semester Class1:course overview and introduction of shell
linux
程序员老赵2 天前
Docker 部署 Redmine:老牌开源项目管理部署实测记录
docker·开源·团队管理
用户120487221612 天前
Linux驱动编译与加载
linux·嵌入式
程序员老赵2 天前
服务器文件不想 SFTP 上传?Docker 跑个 File Browser,浏览器就能管理
服务器·docker·开源
用户805533698032 天前
Input 子系统架构:Core、Handler、Driver 三层是怎么协作的
linux·嵌入式
用户805533698032 天前
RK-Forge外设系列开篇 - 把板子从「能启动」变成「能用」:Ethernet/SPI/MMC 三个纯接线外设
linux·github·嵌入式
七歌杜金房2 天前
我终于又有了自己的 Linux 电脑
linux·debian·mac
tntxia3 天前
linux curl命令详解_curl详解
linux
扛枪的书生3 天前
Linux 网络管理器用法速查
linux