gpt4 book ai didi

python - docker.from_env()返回FileNotFoundError:[Errno 2]没有这样的文件或目录

转载 作者:行者123 更新时间:2023-12-02 19:44:36 30 4
gpt4 key购买 nike

在Windows 10中运行的Docker(19.03.12)
一个装有Python 3.7.3的容器,pip install docker(4.3.1),
运行docker.from_env()时,返回失败。
有人可以帮忙吗?谢谢!

Python 3.7.3 (default, Jul 25 2020, 13:03:44)
[GCC 8.3.0] on linux
Type "help", "copyright", "credits" or "license" for more information.
>>> import docker
>>> docker.from_env()
Traceback (most recent call last):
File "/usr/lib/python3/dist-packages/urllib3/connectionpool.py", line 600, in urlopen
chunked=chunked)
File "/usr/lib/python3/dist-packages/urllib3/connectionpool.py", line 354, in _make_request
conn.request(method, url, **httplib_request_kw)
File "/usr/lib/python3.7/http/client.py", line 1244, in request
self._send_request(method, url, body, headers, encode_chunked)
File "/usr/lib/python3.7/http/client.py", line 1290, in _send_request
self.endheaders(body, encode_chunked=encode_chunked)
File "/usr/lib/python3.7/http/client.py", line 1239, in endheaders
self._send_output(message_body, encode_chunked=encode_chunked)
File "/usr/lib/python3.7/http/client.py", line 1026, in _send_output
self.send(msg)
File "/usr/lib/python3.7/http/client.py", line 966, in send
self.connect()
File "/usr/local/lib/python3.7/dist-packages/docker/transport/unixconn.py", line 43, in connect
sock.connect(self.unix_socket)
FileNotFoundError: [Errno 2] No such file or directory

最佳答案

答案在这里:
How do you mount the docker socket on Windows?
第二个答案对我有用。
docker run --rm -it -v“//var/run/docker.sock://var/run/docker.sock” image_with_docker docker版本
我没有使用引号。仅:(主机路径和容器路径都有双/首位)
docker run --rm -it -v //var/run/docker.sock://var/run/docker.sock image_with_docker docker版本

关于python - docker.from_env()返回FileNotFoundError:[Errno 2]没有这样的文件或目录,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/64273480/

30 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com