docker desktop for mac os如何使用本地代理

在macbook上弄了个代理,然后按照网上所说的去配代理

然后测试下

docker pull busybox

结果无反应,超时。我去!!!

鼓捣了半天,看了docker官网,问了chatgpt ,按照它们所说的试了下也没用,最后还是在stackoverflow上找到关键信息, thank stackoverflow, 真的是技术宝库

Why a locally-bound proxy doesn't work

The Problem

If you're running a locally-bound proxy, e.g. listening on 127.0.0.1:8989, it WON'T WORK in Docker for Mac. From the Docker documentation:

I want to connect from a container to a service on the host

The Mac has a changing IP address (or none if you have no network access). Our current recommendation is to attach an unused IP to the lo0 interface on the Mac; for example: sudo ifconfig lo0 alias 10.200.10.1/24, and make sure that your service is listening on this address or 0.0.0.0 (ie not 127.0.0.1). Then containers can connect to this address.

The similar is for Docker server side. (To understand the server side and client side of Docker, try to run docker version.) And the server side runs on a virtualization layer which has its own localhost. Therefore, it won't connect to the proxy server on the localhost of the host OS.

The solution

So, if you're using a locally-bound proxy like me, basically you would have to do the following things to make it work with Docker for Mac:

  1. Make your proxy server listen on 0.0.0.0 instead of 127.0.0.1Caution: you'll need proper firewall configuration to prevent malicious access to it.

  2. Add a loopback alias to the lo0 interface, e.g. 10.200.10.1/24:

     sudo ifconfig lo0 alias 10.200.10.1/24
    
  3. Set HTTP and/or HTTPS proxy to 10.200.10.1:8989 from Preferences in Docker tray menu (assume that the proxy server is listening on port 8989).

After that, test the proxy settings by running a command in a new container from an image which is not downloaded:

$ docker rmi -f hello-world
  ...

$ docker run hello-world
Unable to find image 'hello-world:latest' locally
latest: Pulling from library/hello-world

c04b14da8d14: Pull complete 
Digest: sha256:0256e8a36e2070f7bf2d0b0763dbabdd67798512411de4cdcf9431a1feb60fd9
Status: Downloaded newer image for hello-world:latest
  ...

Notice: the loopback alias set by ifconfig does not preserve after a reboot. To make it persistent is another topic. Please check this blog post in Japanese (Google Translate may help).

Share

原文链接

Cannot download Docker images behind a proxy - Stack Overflowicon-default.png?t=N7T8https://stackoverflow.com/questions/23111631/cannot-download-docker-images-behind-a-proxy/41544629#41544629

 按照帖子的方法,把代理地址设成了10.200.20.1,再试下,成功了,爽!

另外提到这个设置lo0的别名方式再重启电脑后就会消失。

接着就找找怎么持久化这个配置的办法

Just create a new launch demon file and configure it like so:

sudo vi /Library/LaunchDaemons/org.my.ifconfig.plist


<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple Computer//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<dict>
    <key>Label</key>
    <string>org.my.ifconfig</string>
    <key>RunAtLoad</key>
    <true/>
    <key>ProgramArguments</key>
    <array>
      <string>/sbin/ifconfig</string>
      <string>lo0</string>
      <string>alias</string>
      <string>YourIpHere</string>
    </array>
</dict>
</plist>

原文链接

https://medium.com/@david.limkys/permanently-create-an-ifconfig-loopback-alias-macos-b7c93a8b0dbicon-default.png?t=N7T8https://medium.com/@david.limkys/permanently-create-an-ifconfig-loopback-alias-macos-b7c93a8b0db

本文来自互联网用户投稿,该文观点仅代表作者本人,不代表本站立场。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如若转载,请注明出处:http://www.mfbz.cn/a/713990.html

如若内容造成侵权/违法违规/事实不符,请联系我们进行投诉反馈qq邮箱809451989@qq.com,一经查实,立即删除!

相关文章

PCL 基于八叉树的去噪滤波

目录 一、算法原理1、原理概述2、参考文献二、代码实现三、结果展示1、滤波前2、滤波后本文由CSDN点云侠原创,原文链接。如果你不是在点云侠的博客中看到该文章,那么此处便是不要脸的爬虫与GPT。 一、算法原理 1、原理概述 使用八叉树对点云进行噪点删除的滤波方法实现。 …

C学习自学笔记-会陆续完善对应章节编程经典例子

C学习笔记 0>C语言概述 为什么学习C语言 1&#xff09;C的起源和发展------了解即可 B语言、C语言、C语言的产生地&#xff1a;都出自 美国贝尔实验室 2&#xff09;C的特点 优点&#xff1a;代码量小、速度快、功能强大 缺点&#xff1a;危险性高、开发周期长、可移植性…

UI学习--分栏控制器

UI学习 分栏控制器基础概念用法 分栏控制器高级高级属性 总结 分栏控制器基础 概念 分栏控制器可以理解为一个容器&#xff0c;可以容纳多个子视图控制器&#xff0c;并通过选项卡的方式进行切换。每个选项卡都与一个特定的视图控制器相关联&#xff0c;当用户点击不同的选项…

JUC并发编程第十三章——读写锁、邮戳锁

本章路线总纲 无锁——>独占锁——>读写锁——>邮戳锁 1 关于锁的面试题 你知道Java里面有那些锁你说说你用过的锁&#xff0c;锁饥饿问题是什么&#xff1f;有没有比读写锁更快的锁StampedLock知道吗&#xff1f;&#xff08;邮戳锁/票据锁&#xff09;ReentrantR…

「动态规划」如何求乘积最大子数组?

152. 乘积最大子数组https://leetcode.cn/problems/maximum-product-subarray/description/ 给你一个整数数组nums&#xff0c;请你找出数组中乘积最大的非空连续子数组&#xff08;该子数组中至少包含一个数字&#xff09;&#xff0c;并返回该子数组所对应的乘积。测试用例的…

WebGL学习【焕新计划】

WebGL基础 在正式进入webgl之前&#xff0c;我想有必要简单了解一下渲染管线&#xff0c;毕竟它贯穿webgl学习的整个过程。 渲染管线流程图&#xff1a; webgl着色器简单语法&#xff1a; 在GLSL&#xff08;OpenGL Shading Language&#xff09;中&#xff0c;常见的变量类…

企业化运维(4)_tomcat

###1.配置tomcat### 可以将tomcat部署在server2主机&#xff0c;与nginx主服务器分开&#xff0c;便于进行交互存储。 下载安装jdk与tomcat&#xff0c;并开启服务&#xff0c;便可以在浏览器进行访问。 [rootserver3 ~]# rpm -ivh jdk-8u121-linux-x64.rpm [rootserver3 ~]#…

Mybatis-Plus多种批量插入方案对比

背景 六月某日上线了一个日报表任务&#xff0c;因是第一次上线&#xff0c;故需要为历史所有日期都初始化一次报表数据 在执行过程中发现新增特别的慢&#xff1a;插入十万条左右的数据&#xff0c;SQL执行耗费高达三分多钟 因很早就听闻过mybatis-plus的[伪]批量新增的问题&…

万事开头难——Java实现俄罗斯小方块【第一步】

目录 技术实现&#xff1a; 1.初始化游戏窗口&#xff1b; 1.1 什么是窗口&#xff1a; 1.2 Swing 1.3 JFrame创建窗口&#xff1a; 1.3.1创建窗口的逻辑 1.3.2.设置简单的页面 1.3.3.优化 1.3.4.设置标题 1.4 创建游戏窗口 技术实现&#xff1a; 1.初始化游戏窗口&am…

【CT】LeetCode手撕—20. 有效的括号

题目 原题连接&#xff1a;20. 有效的括号 1- 思路 模式识别 模式1&#xff1a;括号左右匹配 ——> 借助栈来实现 ——> Deque<Character> deque new LinkedList<>()模式2&#xff1a;顺序匹配 ——> 用 if 判断 具体思路 1.遇到左括号 直接入栈相应…

ARM32开发--电源管理单元

知不足而奋进 望远山而前行 目录 文章目录 前言 学习目标 学习内容 PMU 电源域 VDD/VDDA域 备份域 1.2V域 省电模式 睡眠模式 深度睡眠模式 待机模式 几种模式总结 WFI和WFE指令 案例需求 模式初始化 源码 总结 前言 在嵌入式系统中&#xff0c;有效的电池管…

【AI基础】第六步:纯天然保姆喂饭级-安装并运行qwen2-7b

整体步骤类似于 【AI基础】第五步&#xff1a;纯天然保姆喂饭级-安装并运行chatglm3-6b-CSDN博客。 此系列文章列表&#xff1a; 【AI基础】概览 【AI基础】第一步&#xff1a;安装python开发环境-windows篇_下载安装ai环境python 【AI基础】第一步&#xff1a;安装python开发环…

面试题 17.05. 字母与数字

链接&#xff1a;. - 力扣&#xff08;LeetCode&#xff09; 题解&#xff1a;把字母看成1&#xff0c;把数字看为-1&#xff0c;将题目变为求的和为0的最长连续子数组 class Solution { public:vector<string> findLongestSubarray(vector<string>& array) …

MySQL查询练习题1.平均工资2.查询各部门的总薪水3.查询总薪水排名第二的部门4.查询姓名重复的员工信息5.查询各部门薪水大于900的男性员工的平均薪水

创建一个员工表emp&#xff0c;包含字段&#xff1a;姓名name&#xff0c;性别sex&#xff0c;部门depart&#xff0c;工资salary create table emp(name varchar(30) not null,sex varchar(30) not null,depart int not null,salary int not null); 插入数据打印为 mysql>…

Windows Server 2008 r2 IIS .NET

Windows Server 2008 r2 IIS .NET

2-2 基于matlab的变邻域

基于matlab的变邻域&#xff0c;含变惯性权重策略的自适应离散粒子群算法&#xff0c;适应函数是多式联运路径优化距离。有10城市、30城市、75城市三个案例。可直接运行。 2-2 路径规划 自适应离散粒子群算法 - 小红书 (xiaohongshu.com)

MySQL基础——多表查询和事务

目录 1多表关系 2多表查询概述 3连接查询 3.1内连接 3.2左外连接 3.3右外连接 3.4自连接 4联合查询 5子查询 5.1标量子查询(子查询结果为单个值) 5.2列子查询(子查询结果为一列) 5.3行子查询(子查询结果为一行) 5.4表子查询(子查询结果为多行多列) 6事务简介和操…

模拟电子技术基础(二)--PN结

PN结的本质 芯片都是由硅晶体制成&#xff0c;单个硅原子最外层有带有4个电子 在纯硅当中这些电子会两两形成共价键&#xff0c;此时周围形成非常稳定的八电子结构 在一个回路中&#xff0c;灯泡不亮&#xff0c;不导通&#xff0c;因为电池无法吸引其中的电子离开&#xff0c…

机器学习在医学领域中的应用|文献精析·24-06-13

小罗碎碎念 2024-06-13&#xff5c;文献精析&#xff1a;机器学习在医学领域中的应用 为了系统性地和大家梳理一下机器学习在医学领域中的应用&#xff0c;我特意去找了一篇文献&#xff0c;把其中有价值的信息筛选出来了。但是我没选的内容不代表不重要&#xff0c;感兴趣的可…

高分论文密码---大尺度空间模拟预测与数字制图

大尺度空间模拟预测和数字制图技术和不确定性分析广泛应用于高分SCI论文之中&#xff0c;号称高分论文密码。大尺度模拟技术可以从不同时空尺度阐明农业生态环境领域的内在机理和时空变化规律&#xff0c;又可以为复杂的机理过程模型大尺度模拟提供技术基础。我们将结合一些经典…