cdfmlr / muvtuber

Makes your AI vtuber
445 stars 75 forks source link

我在Mac上用shadow racket代理可以访问chatgpt,我应该怎么设置docker才能让docker走shadowracket代理访问chatgpt? #51

Closed JackChow6 closed 1 year ago

JackChow6 commented 1 year ago

2023-06-05 22:01:07 2023-06-05 22:01:07 During handling of the above exception, another exception occurred: 2023-06-05 22:01:07 2023-06-05 22:01:07 Traceback (most recent call last): 2023-06-05 22:01:07 File "/usr/local/lib/python3.10/site-packages/requests/adapters.py", line 489, in send 2023-06-05 22:01:07 resp = conn.urlopen( 2023-06-05 22:01:07 File "/usr/local/lib/python3.10/site-packages/urllib3/connectionpool.py", line 787, in urlopen 2023-06-05 22:01:07 retries = retries.increment( 2023-06-05 22:01:07 File "/usr/local/lib/python3.10/site-packages/urllib3/util/retry.py", line 592, in increment 2023-06-05 22:01:07 raise MaxRetryError(_pool, url, error or ResponseError(cause)) 2023-06-05 22:01:07 urllib3.exceptions.MaxRetryError: HTTPSConnectionPool(host='openaipublic.blob.core.windows.net', port=443): Max retries exceeded with url: /encodings/cl100k_base.tiktoken (Caused by ProxyError('Cannot connect to proxy.', NewConnectionError('<urllib3.connection.HTTPSConnection object at 0xffffa80f2230>: Failed to establish a new connection: [Errno -2] Name or service not known'))) 2023-06-05 22:01:07 2023-06-05 22:01:07 During handling of the above exception, another exception occurred: 2023-06-05 22:01:07 2023-06-05 22:01:07 Traceback (most recent call last): 2023-06-05 22:01:07 File "/usr/local/lib/python3.10/site-packages/grpc/_server.py", line 444, in _call_behavior 2023-06-05 22:01:07 response_or_iterator = behavior(argument, context) 2023-06-05 22:01:07 File "/app/chatgpt/grpcapi.py", line 37, in NewSession 2023-06-05 22:01:07 session_id = self.multiChatGPT.new_session(config) 2023-06-05 22:01:07 File "/app/chatgpt/chatbot.py", line 289, in new_session 2023-06-05 22:01:07 self.chatgpts[session_id] = ChatGPTProxy( 2023-06-05 22:01:07 File "/app/chatgpt/chatbot.py", line 189, in init 2023-06-05 22:01:07 self.renew() 2023-06-05 22:01:07 File "/app/chatgpt/chatbot.py", line 193, in renew 2023-06-05 22:01:07 self.chatgpt = self._new_chatgpt(self.config) 2023-06-05 22:01:07 File "/app/chatgpt/chatbot.py", line 207, in _new_chatgpt 2023-06-05 22:01:07 new_chatgpt = ChatGPTv3(config={ 2023-06-05 22:01:07 File "/app/chatgpt/chatbot.py", line 94, in init 2023-06-05 22:01:07 self.chatbot = ChatbotV3( 2023-06-05 22:01:07 File "/usr/local/lib/python3.10/site-packages/revChatGPT/V3.py", line 68, in init 2023-06-05 22:01:07 if self.get_token_count("default") > self.max_tokens: 2023-06-05 22:01:07 File "/usr/local/lib/python3.10/site-packages/revChatGPT/V3.py", line 116, in get_token_count 2023-06-05 22:01:07 encoding = tiktoken.encoding_for_model(self.engine) 2023-06-05 22:01:07 File "/usr/local/lib/python3.10/site-packages/tiktoken/model.py", line 75, in encoding_for_model 2023-06-05 22:01:07 return get_encoding(encoding_name) 2023-06-05 22:01:07 File "/usr/local/lib/python3.10/site-packages/tiktoken/registry.py", line 63, in get_encoding 2023-06-05 22:01:07 enc = Encoding(constructor()) 2023-06-05 22:01:07 File "/usr/local/lib/python3.10/site-packages/tiktoken_ext/openai_public.py", line 64, in cl100k_base 2023-06-05 22:01:07 mergeable_ranks = load_tiktoken_bpe( 2023-06-05 22:01:07 File "/usr/local/lib/python3.10/site-packages/tiktoken/load.py", line 114, in load_tiktoken_bpe 2023-06-05 22:01:07 contents = read_file_cached(tiktoken_bpe_file) 2023-06-05 22:01:07 File "/usr/local/lib/python3.10/site-packages/tiktoken/load.py", line 46, in read_file_cached 2023-06-05 22:01:07 contents = read_file(blobpath) 2023-06-05 22:01:07 File "/usr/local/lib/python3.10/site-packages/tiktoken/load.py", line 24, in read_file 2023-06-05 22:01:07 return requests.get(blobpath).content 2023-06-05 22:01:07 File "/usr/local/lib/python3.10/site-packages/requests/api.py", line 73, in get 2023-06-05 22:01:07 return request("get", url, params=params, kwargs) 2023-06-05 22:01:07 File "/usr/local/lib/python3.10/site-packages/requests/api.py", line 59, in request 2023-06-05 22:01:07 return session.request(method=method, url=url, kwargs) 2023-06-05 22:01:07 File "/usr/local/lib/python3.10/site-packages/requests/sessions.py", line 587, in request 2023-06-05 22:01:07 resp = self.send(prep, send_kwargs) 2023-06-05 22:01:07 File "/usr/local/lib/python3.10/site-packages/requests/sessions.py", line 701, in send 2023-06-05 22:01:07 r = adapter.send(request, **kwargs) 2023-06-05 22:01:07 File "/usr/local/lib/python3.10/site-packages/requests/adapters.py", line 559, in send 2023-06-05 22:01:07 raise ProxyError(e, request=request) 2023-06-05 22:01:07 requests.exceptions.ProxyError: HTTPSConnectionPool(host='openaipublic.blob.core.windows.net', port=443): Max retries exceeded with url: /encodings/cl100k_base.tiktoken (Caused by ProxyError('Cannot connect to proxy.', NewConnectionError('<urllib3.connection.HTTPSConnection object at 0xffffa80f2230>: Failed to establish a new connection: [Errno -2] Name or service not known')))

JackChow6 commented 1 year ago
image
JackChow6 commented 1 year ago
image
JackChow6 commented 1 year ago
image
JackChow6 commented 1 year ago
image
JackChow6 commented 1 year ago
image
JackChow6 commented 1 year ago

以上是我所有的设置,但是仍显示错误,不知道问题出在哪

cdfmlr commented 1 year ago

我觉得应该需要修改两个地方:

  1. 在代理软件中将 http://<IP>:1000 改为 http://0.0.0.0:1000
  2. 在 docker-compose.yml 中,将 HTTP_PROXYHTTPS_PROXY 的值修改为 http://host.docker.internal:1000

另外,我有个疑问,为什么这个 docker desktop (好像是吧)显示的代理:

image

与 docker-compose.yml 里配置设置的不一样:

image
JackChow6 commented 1 year ago

按照您的意见修改完后仍然报错

JackChow6 commented 1 year ago

我尝试ping ping host.docker.internal PING host.docker.internal (240.0.0.71): 56 data bytes 64 bytes from 240.0.0.71: icmp_seq=0 ttl=64 time=0.152 ms 64 bytes from 240.0.0.71: icmp_seq=1 ttl=64 time=0.300 ms 64 bytes from 240.0.0.71: icmp_seq=2 ttl=64 time=0.381 ms 64 bytes from 240.0.0.71: icmp_seq=3 ttl=64 time=0.368 ms 64 bytes from 240.0.0.71: icmp_seq=4 ttl=64 time=0.325 ms 64 bytes from 240.0.0.71: icmp_seq=5 ttl=64 time=0.213 ms 64 bytes from 240.0.0.71: icmp_seq=6 ttl=64 time=0.240 ms 64 bytes from 240.0.0.71: icmp_seq=7 ttl=64 time=0.185 ms 64 bytes from 240.0.0.71: icmp_seq=8 ttl=64 time=0.268 ms 64 bytes from 240.0.0.71: icmp_seq=9 ttl=64 time=0.354 ms 64 bytes from 240.0.0.71: icmp_seq=10 ttl=64 time=0.387 ms 64 bytes from 240.0.0.71: icmp_seq=11 ttl=64 time=0.308 ms

JackChow6 commented 1 year ago

ping 172.17.0.1:1000 PING 172.17.0.1:1000 (240.0.1.206): 56 data bytes 64 bytes from 240.0.1.206: icmp_seq=0 ttl=64 time=0.188 ms 64 bytes from 240.0.1.206: icmp_seq=1 ttl=64 time=0.278 ms 64 bytes from 240.0.1.206: icmp_seq=2 ttl=64 time=0.227 ms 64 bytes from 240.0.1.206: icmp_seq=3 ttl=64 time=0.319 ms 64 bytes from 240.0.1.206: icmp_seq=4 ttl=64 time=0.384 ms 64 bytes from 240.0.1.206: icmp_seq=5 ttl=64 time=0.276 ms ^C --- 172.17.0.1:1000 ping statistics --- 6 packets transmitted, 6 packets received, 0.0% packet loss round-trip min/avg/max/stddev = 0.188/0.279/0.384/0.063 ms

cdfmlr commented 1 year ago
  1. 先在本地试试:
nc localhost 1000 -v
# 显示 "Connection to ... succeeded!" 则成功

telnet localhost 1000
# 显示 "Connected to ..." 则成功
  1. 再试试在容器里:
nc host.docker.internal 1000 -v

telnet host.docker.internal 1000

看看能否成功连接。

(万一 nc 和 telnet 都没有的话随便装一个吧)

JackChow6 commented 1 year ago

telnet localhost 1000 Trying ::1... telnet: connect to address ::1: Connection refused Trying 127.0.0.1... telnet: connect to address 127.0.0.1: Connection refused telnet: Unable to connect to remote host

显示失败了

cdfmlr commented 1 year ago

那说明你的代理软件没有配置好吧

JackChow6 commented 1 year ago
image
JackChow6 commented 1 year ago

在哪里设置呢

cdfmlr commented 1 year ago

再改回 127.0.0.1 试试?😅

JackChow6 commented 1 year ago

我吧端口重置 为原来的,就"Connection to ... succeeded!"

cdfmlr commented 1 year ago

那你把 docker-compose.yml 里面的配置改成对应的呗

JackChow6 commented 1 year ago

environment:

本地代理的地址:需要根据每个人的情况具体设置

  # host.docker.internal 是 docker desktop 默认带有的访问宿主机的域名,
  # 但不一定有效,例如我的 docker vm 访问宿主机的 ip 需要用 192.168.5.2
  - HTTP_PROXY=http://host.docker.internal:1082
  - HTTPS_PROXY=http://host.docker.internal:1082

这样设置还是报错诶

JackChow6 commented 1 year ago

During handling of the above exception, another exception occurred: 2023-06-06 19:35:25 2023-06-06 19:35:25 Traceback (most recent call last): 2023-06-06 19:35:25 File "/usr/local/lib/python3.10/site-packages/grpc/_server.py", line 444, in _call_behavior 2023-06-06 19:35:25 response_or_iterator = behavior(argument, context) 2023-06-06 19:35:25 File "/app/chatgpt/grpcapi.py", line 37, in NewSession 2023-06-06 19:35:25 session_id = self.multiChatGPT.new_session(config) 2023-06-06 19:35:25 File "/app/chatgpt/chatbot.py", line 289, in new_session 2023-06-06 19:35:25 self.chatgpts[session_id] = ChatGPTProxy( 2023-06-06 19:35:25 File "/app/chatgpt/chatbot.py", line 189, in init 2023-06-06 19:35:25 self.renew() 2023-06-06 19:35:25 File "/app/chatgpt/chatbot.py", line 193, in renew 2023-06-06 19:35:25 self.chatgpt = self._new_chatgpt(self.config) 2023-06-06 19:35:25 File "/app/chatgpt/chatbot.py", line 207, in _new_chatgpt 2023-06-06 19:35:25 new_chatgpt = ChatGPTv3(config={ 2023-06-06 19:35:25 File "/app/chatgpt/chatbot.py", line 94, in init 2023-06-06 19:35:25 self.chatbot = ChatbotV3( 2023-06-06 19:35:25 File "/usr/local/lib/python3.10/site-packages/revChatGPT/V3.py", line 68, in init 2023-06-06 19:35:25 if self.get_token_count("default") > self.max_tokens: 2023-06-06 19:35:25 File "/usr/local/lib/python3.10/site-packages/revChatGPT/V3.py", line 116, in get_token_count 2023-06-06 19:35:25 encoding = tiktoken.encoding_for_model(self.engine) 2023-06-06 19:35:25 File "/usr/local/lib/python3.10/site-packages/tiktoken/model.py", line 75, in encoding_for_model 2023-06-06 19:35:25 return get_encoding(encoding_name) 2023-06-06 19:35:25 File "/usr/local/lib/python3.10/site-packages/tiktoken/registry.py", line 63, in get_encoding 2023-06-06 19:35:25 enc = Encoding(constructor()) 2023-06-06 19:35:25 File "/usr/local/lib/python3.10/site-packages/tiktoken_ext/openai_public.py", line 64, in cl100k_base 2023-06-06 19:35:25 mergeable_ranks = load_tiktoken_bpe( 2023-06-06 19:35:25 File "/usr/local/lib/python3.10/site-packages/tiktoken/load.py", line 114, in load_tiktoken_bpe 2023-06-06 19:35:25 contents = read_file_cached(tiktoken_bpe_file) 2023-06-06 19:35:25 File "/usr/local/lib/python3.10/site-packages/tiktoken/load.py", line 46, in read_file_cached 2023-06-06 19:35:25 contents = read_file(blobpath) 2023-06-06 19:35:25 File "/usr/local/lib/python3.10/site-packages/tiktoken/load.py", line 24, in read_file 2023-06-06 19:35:25 return requests.get(blobpath).content 2023-06-06 19:35:25 File "/usr/local/lib/python3.10/site-packages/requests/api.py", line 73, in get 2023-06-06 19:35:25 return request("get", url, params=params, kwargs) 2023-06-06 19:35:25 File "/usr/local/lib/python3.10/site-packages/requests/api.py", line 59, in request 2023-06-06 19:35:25 return session.request(method=method, url=url, kwargs) 2023-06-06 19:35:25 File "/usr/local/lib/python3.10/site-packages/requests/sessions.py", line 587, in request 2023-06-06 19:35:25 resp = self.send(prep, send_kwargs) 2023-06-06 19:35:25 File "/usr/local/lib/python3.10/site-packages/requests/sessions.py", line 701, in send 2023-06-06 19:35:25 r = adapter.send(request, **kwargs) 2023-06-06 19:35:25 File "/usr/local/lib/python3.10/site-packages/requests/adapters.py", line 559, in send 2023-06-06 19:35:25 raise ProxyError(e, request=request) 2023-06-06 19:35:25 requests.exceptions.ProxyError: HTTPSConnectionPool(host='openaipublic.blob.core.windows.net', port=443): Max retries exceeded with url: /encodings/cl100k_base.tiktoken (Caused by ProxyError('Cannot connect to proxy.', NewConnectionError('<urllib3.connection.HTTPSConnection object at 0xffff8821b4c0>: Failed to establish a new connection: [Errno 111] Connection refused')))

JackChow6 commented 1 year ago
image

然后这个还是不一样 好奇怪

cdfmlr commented 1 year ago

你重启服务组了没?重新 docker compose up -d 一下试试

JackChow6 commented 1 year ago

重组之后代理显示正常,但还是报错

cdfmlr commented 1 year ago

你在容器里试试能 telnet 连到代理吗

JackChow6 commented 1 year ago

(base) zjk-macminim1@Zjk-MacdeMac-mini muvtuber % telnet host.docker.internal 1082 Trying 240.0.0.33... Connected to host.docker.internal. Escape character is '^]'. Connection closed by foreign host.

JackChow6 commented 1 year ago

(base) zjk-macminim1@Zjk-MacdeMac-mini muvtuber % nc host.docker.internal 1082 -v Connection to host.docker.internal port 1082 [tcp/amt-esd-prot] succeeded!

cdfmlr commented 1 year ago

(base) zjk-macminim1@Zjk-MacdeMac-mini

啊?这不是容器内叭 🥺

你试试这种炼金去的:

docker compose exec chatgpt_chatbot sh
JackChow6 commented 1 year ago

(base) zjk-macminim1@Zjk-MacdeMac-mini muvtuber % docker compose exec chatgpt_chatbot sh

telnet host.docker.internal 1082

telnet: could not resolve host.docker.internal/1082: Name or service not known

显示错误

cdfmlr commented 1 year ago

这个 host.docker.internal 按照 docker desktop 的文档应该是可用的。

所以还是代理设置的问题吧,我还是觉得代理要监听 0.0.0.0 应该才能访问到,你再试试改一下?(改完要重启代理软件哦)

JackChow6 commented 1 year ago

(base) zjk-macminim1@Zjk-MacdeMac-mini muvtuber % docker compose exec chatgpt_chatbot sh

telnet host.docker.internal 1082

telnet: could not resolve host.docker.internal/1082: Name or service not known

还是显示错误诶

cdfmlr commented 1 year ago

你在宿主机开一个其他服务,在容器内能访问到嘛

比如宿主机uh:

python -m http.server 8000

然后在里:

telnet host.docker.internal 8000
JackChow6 commented 1 year ago

您使用的代理软件是什么,或许我 change 一下软件就行了?

JackChow6 commented 1 year ago
image

b x不行诶

cdfmlr commented 1 year ago

Docker desktop 文档不是说这个地址是可用的嘛 😭(我自己是用的 colima 所以我不清楚 docker desktop 的具体情况

emmm,开 python 服务之后 mac 弹的那个允许传入网络连接对话框允许了没

JackChow6 commented 1 year ago

允许了的

JackChow6 commented 1 year ago

太难了吧,宝子

cdfmlr commented 1 year ago

这个网络就是很烦,每个人的情况都不一样。解决这个办法挺多的,主要不知道你用啥方案比较方便

你在容器里和 docker 的 vm 里分别 host host.docker.internal 能查到 ip 嘛

JackChow6 commented 1 year ago

请问应该怎么查呢

JackChow6 commented 1 year ago

我ifconfig

(base) zjk-macminim1@Zjk-MacdeMac-mini ~ % ifconfig lo0: flags=8049<UP,LOOPBACK,RUNNING,MULTICAST> mtu 16384 options=1203<RXCSUM,TXCSUM,TXSTATUS,SW_TIMESTAMP> inet 127.0.0.1 netmask 0xff000000 inet6 ::1 prefixlen 128 inet6 fe80::1%lo0 prefixlen 64 scopeid 0x1 nd6 options=201<PERFORMNUD,DAD> gif0: flags=8010<POINTOPOINT,MULTICAST> mtu 1280 stf0: flags=0<> mtu 1280 anpi0: flags=8863<UP,BROADCAST,SMART,RUNNING,SIMPLEX,MULTICAST> mtu 1500 options=400 ether aa:26:45:f5:9a:fd inet6 fe80::a826:45ff:fef5:9afd%anpi0 prefixlen 64 scopeid 0x4 nd6 options=201<PERFORMNUD,DAD> media: none status: inactive anpi1: flags=8863<UP,BROADCAST,SMART,RUNNING,SIMPLEX,MULTICAST> mtu 1500 options=400 ether aa:26:45:f5:9a:fe inet6 fe80::a826:45ff:fef5:9afe%anpi1 prefixlen 64 scopeid 0x5 nd6 options=201<PERFORMNUD,DAD> media: none status: inactive en0: flags=8863<UP,BROADCAST,SMART,RUNNING,SIMPLEX,MULTICAST> mtu 1500 options=50b<RXCSUM,TXCSUM,VLAN_HWTAGGING,AV,CHANNEL_IO> ether 14:98:77:63:04:da nd6 options=201<PERFORMNUD,DAD> media: 10baseT/UTP (none) status: inactive en4: flags=8863<UP,BROADCAST,SMART,RUNNING,SIMPLEX,MULTICAST> mtu 1500 options=400 ether aa:26:45:f5:9a:dd nd6 options=201<PERFORMNUD,DAD> media: none status: inactive en5: flags=8863<UP,BROADCAST,SMART,RUNNING,SIMPLEX,MULTICAST> mtu 1500 options=400 ether aa:26:45:f5:9a:de nd6 options=201<PERFORMNUD,DAD> media: none status: inactive en2: flags=8963<UP,BROADCAST,SMART,RUNNING,PROMISC,SIMPLEX,MULTICAST> mtu 1500 options=460<TSO4,TSO6,CHANNEL_IO> ether 36:0f:86:bf:69:40 media: autoselect status: inactive en3: flags=8963<UP,BROADCAST,SMART,RUNNING,PROMISC,SIMPLEX,MULTICAST> mtu 1500 options=460<TSO4,TSO6,CHANNEL_IO> ether 36:0f:86:bf:69:44 media: autoselect status: inactive ap1: flags=8802<BROADCAST,SIMPLEX,MULTICAST> mtu 1500 options=400 ether 36:98:77:5d:67:96 media: autoselect en1: flags=8863<UP,BROADCAST,SMART,RUNNING,SIMPLEX,MULTICAST> mtu 1500 options=6463<RXCSUM,TXCSUM,TSO4,TSO6,CHANNEL_IO,PARTIAL_CSUM,ZEROINVERT_CSUM> ether 14:98:77:5d:67:96 inet6 fe80::8b2:d8c:e6d9:bda8%en1 prefixlen 64 secured scopeid 0xc inet 192.168.8.18 netmask 0xffffff00 broadcast 192.168.8.255 inet6 2408:8956:8640:6b1:48e:8e59:fe09:55c4 prefixlen 64 autoconf secured inet6 2408:8956:8640:6b1:b8b4:edc:c54a:4cec prefixlen 64 deprecated autoconf temporary inet6 2408:8956:8640:6b1:a844:be50:c30:e3f5 prefixlen 64 deprecated autoconf temporary inet6 2408:8956:8640:6b1:2246:57fc:da7c:2 prefixlen 64 dynamic inet6 2408:8956:8640:6b1:7de8:1102:371f:84a6 prefixlen 64 autoconf temporary nd6 options=201<PERFORMNUD,DAD> media: autoselect status: active bridge0: flags=8863<UP,BROADCAST,SMART,RUNNING,SIMPLEX,MULTICAST> mtu 1500 options=63<RXCSUM,TXCSUM,TSO4,TSO6> ether 36:0f:86:bf:69:40 Configuration: id 0:0:0:0:0:0 priority 0 hellotime 0 fwddelay 0 maxage 0 holdcnt 0 proto stp maxaddr 100 timeout 1200 root id 0:0:0:0:0:0 priority 0 ifcost 0 port 0 ipfilter disabled flags 0x0 member: en2 flags=3<LEARNING,DISCOVER> ifmaxaddr 0 port 9 priority 0 path cost 0 member: en3 flags=3<LEARNING,DISCOVER> ifmaxaddr 0 port 10 priority 0 path cost 0 nd6 options=201<PERFORMNUD,DAD> media: status: inactive awdl0: flags=8843<UP,BROADCAST,RUNNING,SIMPLEX,MULTICAST> mtu 1500 options=6463<RXCSUM,TXCSUM,TSO4,TSO6,CHANNEL_IO,PARTIAL_CSUM,ZEROINVERT_CSUM> ether 62:5e:84:89:58:fb inet6 fe80::605e:84ff:fe89:58fb%awdl0 prefixlen 64 scopeid 0xf nd6 options=201<PERFORMNUD,DAD> media: autoselect status: active llw0: flags=8863<UP,BROADCAST,SMART,RUNNING,SIMPLEX,MULTICAST> mtu 1500 options=400 ether 62:5e:84:89:58:fb inet6 fe80::605e:84ff:fe89:58fb%llw0 prefixlen 64 scopeid 0x10 nd6 options=201<PERFORMNUD,DAD> media: autoselect status: inactive utun0: flags=8051<UP,POINTOPOINT,RUNNING,MULTICAST> mtu 2000 inet6 fe80::3e25:84e7:35b5:b960%utun0 prefixlen 64 scopeid 0x11 nd6 options=201<PERFORMNUD,DAD> utun1: flags=8051<UP,POINTOPOINT,RUNNING,MULTICAST> mtu 1000 inet6 fe80::ce81:b1c:bd2c:69e%utun1 prefixlen 64 scopeid 0x12 nd6 options=201<PERFORMNUD,DAD> utun2: flags=8051<UP,POINTOPOINT,RUNNING,MULTICAST> mtu 1380 inet6 fe80::b0f1:bbf3:156a:8c4c%utun2 prefixlen 64 scopeid 0x13 nd6 options=201<PERFORMNUD,DAD> utun3: flags=8051<UP,POINTOPOINT,RUNNING,MULTICAST> mtu 1380 inet6 fe80::d37f:b14b:ef39:f8a2%utun3 prefixlen 64 scopeid 0x14 nd6 options=201<PERFORMNUD,DAD> utun4: flags=8051<UP,POINTOPOINT,RUNNING,MULTICAST> mtu 4000 options=6463<RXCSUM,TXCSUM,TSO4,TSO6,CHANNEL_IO,PARTIAL_CSUM,ZEROINVERT_CSUM> inet 240.0.0.1 --> 240.0.0.1 netmask 0xffffff00 nd6 options=201<PERFORMNUD,DAD>

JackChow6 commented 1 year ago

(base) zjk-macminim1@Zjk-MacdeMac-mini ~ % host host.docker.internal host.docker.internal has address 240.0.0.26 host.docker.internal has address 240.0.0.26

cdfmlr commented 1 year ago

我自己常用的一种手段是在容器内开一个陷阱服务,然后从宿主机去访问这个服务,便记录下了容器眼里宿主机的 ip。大概就这样吧。

除了找出 ip 去连,这个问题其他解决方案也很多:


还有,想起来以前有个老哥说他是这么解决的:

chatgpt的话我通过docker desktop的settings-resources-proxies写了宿主机的ip(我写的就是宿主机以太网下的本地ipv4地址)能正常使用了

JackChow6 commented 1 year ago

i get it ,通过docker desktop的settings-resources-proxies写了宿主机的ip(我写的就是宿主机以太网下的本地ipv4地址),但是得把dockerfile和docker compose 2个文件里的代理都删掉!!!!感谢大佬,晚安

image
JackChow6 commented 1 year ago

i get it ,通过docker desktop的settings-resources-proxies写了宿主机的ip(我写的就是宿主机以太网下的本地ipv4地址),但是得把dockerfile和docker compose 2个文件里的代理都删掉!!!!感谢大佬,晚安

image

我是把他注释掉了

cdfmlr commented 1 year ago

太好了🥹 但是为啥,这个具体是怎么个配法我还是没理解(我没用docker desktop不了解)。

通过docker desktop的settings-resources-proxies写了宿主机的ip(我写的就是宿主机以太网下的本地ipv4地址),

这个是怎么配的呢?我想了解一下在文档里详细写一写。

或者如果你能帮忙 pr 改一改 README 就更棒了🥰

JackChow6 commented 1 year ago

imageimage

因为我们想让docker使用宿主机的代理,所以我们在docker desktop里settings-resources-proxies设置代理地址(宿主机以太网下的本地ipv4地址+代理软件设置的端口),同时把dockerfile和doccker compose 2个文件中的有关proxy的内容注释掉或删除,这个或许会影响docker 走宿主机的代理,最后感谢大佬的提醒[玫瑰][玫瑰][玫瑰]

cdfmlr commented 1 year ago

哦哦,是 Settings -> Resources -> Proxies 的意思啊。这下看懂了。我之前以为是在某个神秘的地方去写某个 settings-resources-proxies 变量 😰 多谢哈,我一会儿给加到文档里去。

JackChow6 commented 1 year ago

这样设置对小白很友好🥰