ubuntu设置网络代理在内网中使用 apt代理、docker代理

ubuntu设置apt 代理

编辑apt 配置文件

sudo vim /etc/apt/apt.conf

添加以下内容

Acquire::http::proxy "http://192.168.0.186:3128";
Acquire::https::proxy "https://192.168.0.186:3128";

测试

root@ecs-3001:~# sudo apt update
Hit:1 https://mirrors.aliyun.com/docker-ce/linux/ubuntu xenial InRelease
Hit:2 http://repo.huaweicloud.com/ubuntu xenial InRelease
Hit:3 http://repo.huaweicloud.com/ubuntu xenial-updates InRelease
Hit:4 http://repo.huaweicloud.com/ubuntu xenial-backports InRelease
Hit:5 http://repo.huaweicloud.com/ubuntu xenial-security InRelease
Reading package lists... Done
Building dependency tree
Reading state information... Done

docker 网络代理

sudo mkdir -p /etc/systemd/system/docker.service.d
sudo touch /etc/systemd/system/docker.service.d/proxy.conf
vim /etc/systemd/system/docker.service.d/proxy.conf

添加以下内容

[Service]
Environment="HTTP_PROXY=http://192.168.0.186:3128"
Environment="HTTPS_PROXY=http://192.168.0.186:3128"
Environment="NO_PROXY=localhost,127.0.0.1"

重启

sudo systemctl daemon-reload
sudo systemctl restart docker

测试

root@ecs-3001:~# docker search nginx
NAME                              DESCRIPTION                                     STARS     OFFICIAL   AUTOMATED
nginx                             Official build of Nginx.                        15325     [OK]
jwilder/nginx-proxy               Automated Nginx reverse proxy for docker con…   2059                 [OK]
richarvey/nginx-php-fpm           Container running Nginx + PHP-FPM capable of…   815                  [OK]
jc21/nginx-proxy-manager          Docker container for managing Nginx proxy ho…   234
linuxserver/nginx                 An Nginx container, brought to you by LinuxS…   151
tiangolo/nginx-rtmp               Docker image with Nginx using the nginx-rtmp…   138                  [OK]
jlesage/nginx-proxy-manager       Docker container for Nginx Proxy Manager        131                  [OK]
alfg/nginx-rtmp                   NGINX, nginx-rtmp-module and FFmpeg from sou…   105                  [OK]
nginxdemos/hello                  NGINX webserver that serves a simple page co…   71                   [OK]

终端代理

系统环境变量添加

export http_proxy=http://192.168.0.186:3128
export https_proxy=http://192.168.0.186:3128
  • 0
    点赞
  • 3
    收藏
    觉得还不错? 一键收藏
  • 2
    评论
要配置Docker网络代理,你可以参考Docker官方文档的配置方法。首先,你需要确定要使用代理服务器的地址和端口。如果你使用的是本地代理,比如localhost:3128,你需要在docker命令添加--network host参数。这样Docker容器将能够正常使用本地代理。如果你使用的是外部IP地址的代理服务器,并且代理本身需要开启Gateway模式,你需要在Docker守护进程的配置文件添加代理设置。具体的配置方法可以参考Linux下安装配置Cntlm代理的教程。完成配置后,你需要重启Docker守护进程使配置生效。你可以使用以下命令来重启Docker守护进程并查看配置是否正确: sudo systemctl daemon-reload sudo systemctl restart docker systemctl show --property=Environment docker /etc/systemd/system/docker.service.d 这样你就成功配置了Docker网络代理。请根据你的实际情况进行相应的配置。<span class="em">1</span><span class="em">2</span><span class="em">3</span> #### 引用[.reference_title] - *1* [快速设置 Docker 的三种网络代理配置](https://blog.csdn.net/peng2hui1314/article/details/124267333)[target="_blank" data-report-click={"spm":"1018.2226.3001.9630","extra":{"utm_source":"vip_chatgpt_common_search_pc_result","utm_medium":"distribute.pc_search_result.none-task-cask-2~all~insert_cask~default-1-null.142^v93^chatsearchT3_1"}}] [.reference_item style="max-width: 50%"] - *2* *3* [Docker 配置网络代理](https://blog.csdn.net/qq_39698985/article/details/123748820)[target="_blank" data-report-click={"spm":"1018.2226.3001.9630","extra":{"utm_source":"vip_chatgpt_common_search_pc_result","utm_medium":"distribute.pc_search_result.none-task-cask-2~all~insert_cask~default-1-null.142^v93^chatsearchT3_1"}}] [.reference_item style="max-width: 50%"] [ .reference_list ]

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论 2
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值