从Mac Docker容器中的botocore.exceptions.EndpointConnectionError

当我试图从在Mac上运行的Docker容器内联系DynamoDB时,我最近开始得到一个EndpointConnectionError(超时后)。 相同的代码和安装程序以前工作正常。

以下是一些示例代码:

>>> from boto3 import resource >>> r = resource('dynamodb') >>> table = r.Table('Users') >>> table.put_item(Item={'id':'987987'}) 

我的〜/ .aws / config:

 [default] output = json region = us-east-1 

我正在使用的代码重build和重新启动容器(从Mac OS):

 #!/bin/sh docker-machine ssh default "docker ps | awk 'NR > 1 {print \$1}' | xargs --no-run-if-empty docker kill" docker build -t <image_name> . docker-machine ssh default "docker run -p 80:80 -v /var/datenight_secret:/var/www/.aws <image_name>" & 

堆栈跟踪:

 Traceback (most recent call last): File "<stdin>", line 1, in <module> File "/usr/local/lib/python3.4/dist-packages/boto3/resources/factory.py", line 518, in do_action response = action(self, *args, **kwargs) File "/usr/local/lib/python3.4/dist-packages/boto3/resources/action.py", line 83, in __call__ response = getattr(parent.meta.client, operation_name)(**params) File "/usr/local/lib/python3.4/dist-packages/botocore/client.py", line 258, in _api_call return self._make_api_call(operation_name, kwargs) File "/usr/local/lib/python3.4/dist-packages/botocore/client.py", line 537, in _make_api_call operation_model, request_dict) File "/usr/local/lib/python3.4/dist-packages/botocore/endpoint.py", line 117, in make_request return self._send_request(request_dict, operation_model) File "/usr/local/lib/python3.4/dist-packages/botocore/endpoint.py", line 146, in _send_request success_response, exception): File "/usr/local/lib/python3.4/dist-packages/botocore/endpoint.py", line 219, in _needs_retry caught_exception=caught_exception) File "/usr/local/lib/python3.4/dist-packages/botocore/hooks.py", line 227, in emit return self._emit(event_name, kwargs) File "/usr/local/lib/python3.4/dist-packages/botocore/hooks.py", line 210, in _emit response = handler(**kwargs) File "/usr/local/lib/python3.4/dist-packages/botocore/retryhandler.py", line 183, in __call__ if self._checker(attempts, response, caught_exception): File "/usr/local/lib/python3.4/dist-packages/botocore/retryhandler.py", line 251, in __call__ caught_exception) File "/usr/local/lib/python3.4/dist-packages/botocore/retryhandler.py", line 274, in _should_retry return self._checker(attempt_number, response, caught_exception) File "/usr/local/lib/python3.4/dist-packages/botocore/retryhandler.py", line 314, in __call__ caught_exception) File "/usr/local/lib/python3.4/dist-packages/botocore/retryhandler.py", line 223, in __call__ attempt_number, caught_exception) File "/usr/local/lib/python3.4/dist-packages/botocore/retryhandler.py", line 356, in _check_caught_exception raise caught_exception botocore.exceptions.EndpointConnectionError: Could not connect to the endpoint URL: "https://dynamodb.us-east-1.amazonaws.com/" 

当我尝试我们东 – 2或欧 – 西1时,我得到相同的行为(挂起很长时间,然后相同的堆栈跟踪)。 相同的configuration和凭证文件在us-east-1 EC2主机上或从我的Mac OS上正常工作。

基于这个问题,我确保HTTP_PROXY和HTTPS_PROXY都是空白的。

Python版本是Python 3.4.3。

运行docker-machine stop default; docker-machine start default docker-machine stop default; docker-machine start default解决了这个问题。 多么深刻的不满意 – 我认为这将是一个有趣的问题,会教我一些关于networking的事情。