tsx81429 发表于 2024-9-4 17:45:06

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

在macbook上弄了个署理,然后按照网上所说的去配署理
https://img-blog.csdnimg.cn/direct/cac6f7a9ec694e4497e2f6206108ee1d.png
然后测试下
   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:
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:
$ 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 Overflowhttps://csdnimg.cn/release/blog_editor_html/release2.3.6/ckeditor/plugins/CsdnLink/icons/icon-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-b7c93a8b0dbhttps://csdnimg.cn/release/blog_editor_html/release2.3.6/ckeditor/plugins/CsdnLink/icons/icon-default.png?t=N7T8https://medium.com/@david.limkys/permanently-create-an-ifconfig-loopback-alias-macos-b7c93a8b0db

免责声明:如果侵犯了您的权益,请联系站长,我们会及时删除侵权内容,谢谢合作!更多信息从访问主页:qidao123.com:ToB企服之家,中国第一个企服评测及商务社交产业平台。
页: [1]
查看完整版本: docker desktop for mac os如何利用当地署理