我向社区致意!当它产生这个错误时,我试图使用docker api(python库)连接到ip:
File "docker_launcher.py", line 12, in <module>
response = [line for line in cli.build(fileobj = f, path='C:\Users\atrestis\ptest')]
File "C:\Python27\lib\site-packages\docker\api\build.py", line 97, in build
timeout=timeout,
File "C:\Python27\lib\site-packages\docker\utils\decorators.py", line 47, in inner
return f(self, *args, **kwargs)
File "C:\Python27\lib\site-packages\docker\client.py", line 108, in _post
return self.post(url, **self._set_request_timeout(kwargs))
File "C:\Python27\lib\site-packages\requests\sessions.py", line 511, in post
return self.request('POST', url, data=data, json=json, **kwargs)
File "C:\Python27\lib\site-packages\requests\sessions.py", line 468, in request
resp = self.send(prep, **send_kwargs)
File "C:\Python27\lib\site-packages\requests\sessions.py", line 576, in send
r = adapter.send(request, **kwargs)
File "C:\Python27\lib\site-packages\requests\adapters.py", line 437, in send
raise ConnectionError(e, request=request)
requests.exceptions.ConnectionError: HTTPConnectionPool(host='192.168.99.1', port=2376): Max retries exceeded with url: /v1.21/build?q=False&pull=False&nocache=False&forcerm=False&rm=False (Caused by strong textNewConnectionError('<requests.packages.urllib3.connection.HTTPConnection object at 0x02BDEC70>: Failed to establish a new connection: [Errno 10061] No connection could be made because the target machine actively refused it',))
这是我的代码:
from io import BytesIO
from docker import Client
dockerfile = '''
# Shared Volume
FROM python:2-onbuild
CMD ["python", "./demo.py" ]
'''
f = BytesIO(dockerfile.encode('utf-8'))
cli = Client(base_url='tcp://192.168.99.1:2376')
response = [line for line in cli.build(fileobj = f, path='C:\User\atrestis\ptest')]
这似乎是TCP-IP的问题。 任何帮助将不胜感激。