docker desktop for mac os如何利用当地署理

打印 上一主题 下一主题

主题 522|帖子 522|积分 1566

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

  • Make your proxy server listen on 0.0.0.0 instead of 127.0.0.1. Caution: you'll need proper firewall configuration to prevent malicious access to it.
  • Add a loopback alias to the lo0 interface, e.g. 10.200.10.1/24:
    1. sudo ifconfig lo0 alias 10.200.10.1/24
    复制代码
  • 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:
  1. $ docker rmi -f hello-world
  2.   ...
  3. $ docker run hello-world
  4. Unable to find image 'hello-world:latest' locally
  5. latest: Pulling from library/hello-world
  6. c04b14da8d14: Pull complete
  7. Digest: sha256:0256e8a36e2070f7bf2d0b0763dbabdd67798512411de4cdcf9431a1feb60fd9
  8. Status: Downloaded newer image for hello-world:latest
  9.   ...
复制代码
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 Overflow
https://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:
  1. sudo vi /Library/LaunchDaemons/org.my.ifconfig.plist
  2. <?xml version="1.0" encoding="UTF-8"?>
  3. <!DOCTYPE plist PUBLIC "-//Apple Computer//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
  4. <plist version="1.0">
  5. <dict>
  6.     <key>Label</key>
  7.     <string>org.my.ifconfig</string>
  8.     <key>RunAtLoad</key>
  9.     <true/>
  10.     <key>ProgramArguments</key>
  11.     <array>
  12.       <string>/sbin/ifconfig</string>
  13.       <string>lo0</string>
  14.       <string>alias</string>
  15.       <string>YourIpHere</string>
  16.     </array>
  17. </dict>
  18. </plist>
复制代码
原文链接
https://medium.com/@david.limkys/permanently-create-an-ifconfig-loopback-alias-macos-b7c93a8b0db
https://medium.com/@david.limkys/permanently-create-an-ifconfig-loopback-alias-macos-b7c93a8b0db

免责声明:如果侵犯了您的权益,请联系站长,我们会及时删除侵权内容,谢谢合作!更多信息从访问主页:qidao123.com:ToB企服之家,中国第一个企服评测及商务社交产业平台。

本帖子中包含更多资源

您需要 登录 才可以下载或查看,没有账号?立即注册

x
回复

使用道具 举报

0 个回复

倒序浏览

快速回复

您需要登录后才可以回帖 登录 or 立即注册

本版积分规则

tsx81429

金牌会员
这个人很懒什么都没写!

标签云

快速回复 返回顶部 返回列表