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
    评论
评论 2
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值