当前位置: 首页 > news >正文

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-worldc04b14da8d14: 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

相关文章:

  • SpringBoot Gradle和Vue 两个项目结构进行解释,说明其作用
  • MySQL支持的四种隔离级别
  • 【Linux】线程池
  • 【Linux】系统文件IO·文件描述符fd
  • Zookeeper 集群的应用场景
  • 【docker1】指令,docker-compose,Dockerfile
  • 刷题——比较版本号
  • Android招聘市场技术要求越来越高,从事三年开发是否应该考虑转行?
  • 【React 】折叠面板,点击展开时再请求数据
  • STM32CubeIDE提示找不到头文件(No such file or directory)的解决办法
  • python3GUI--ktv点歌软件By:PyQt5(附下载地址)
  • USB - USB在消费领域的应用
  • 【nest】puppeteer 使用 addScriptTag 在页面中添加方法的方式
  • Gnu/Linux 之 C 语言函数列表初步整理
  • Python题目
  • [case10]使用RSQL实现端到端的动态查询
  • 【干货分享】SpringCloud微服务架构分布式组件如何共享session对象
  • co.js - 让异步代码同步化
  • eclipse的离线汉化
  • httpie使用详解
  • JavaSE小实践1:Java爬取斗图网站的所有表情包
  • MYSQL如何对数据进行自动化升级--以如果某数据表存在并且某字段不存在时则执行更新操作为例...
  • Odoo domain写法及运用
  • Webpack入门之遇到的那些坑,系列示例Demo
  • 从零搭建Koa2 Server
  • 大主子表关联的性能优化方法
  • 力扣(LeetCode)21
  • 前端面试之CSS3新特性
  • 深度学习入门:10门免费线上课程推荐
  • 首页查询功能的一次实现过程
  • 正则与JS中的正则
  • ionic异常记录
  • LIGO、Virgo第三轮探测告捷,同时探测到一对黑洞合并产生的引力波事件 ...
  • 策略 : 一文教你成为人工智能(AI)领域专家
  • ​软考-高级-系统架构设计师教程(清华第2版)【第9章 软件可靠性基础知识(P320~344)-思维导图】​
  • #LLM入门|Prompt#3.3_存储_Memory
  • #面试系列-腾讯后端一面
  • (2/2) 为了理解 UWP 的启动流程,我从零开始创建了一个 UWP 程序
  • (附源码)ssm户外用品商城 毕业设计 112346
  • (转)GCC在C语言中内嵌汇编 asm __volatile__
  • (转)visual stdio 书签功能介绍
  • .bat批处理(十):从路径字符串中截取盘符、文件名、后缀名等信息
  • .config、Kconfig、***_defconfig之间的关系和工作原理
  • .NET CLR Hosting 简介
  • .net core 6 集成和使用 mongodb
  • .NET/C# 编译期能确定的字符串会在字符串暂存池中不会被 GC 垃圾回收掉
  • .NET/C# 使用 #if 和 Conditional 特性来按条件编译代码的不同原理和适用场景
  • .Net环境下的缓存技术介绍
  • .so文件(linux系统)
  • .vollhavhelp-V-XXXXXXXX勒索病毒的最新威胁:如何恢复您的数据?
  • .考试倒计时43天!来提分啦!
  • /proc/vmstat 详解
  • :如何用SQL脚本保存存储过程返回的结果集
  • [000-01-030].Zookeeper学习大纲
  • [20150904]exp slow.txt